简体   繁体   English

如何使用Selenium Web驱动程序python单击网页中目录列表的不同链接

[英]how to click on different links of directory listing in a web page using selenium web-driver python

I am scraping a website justdial where I need to click on every button ( Enquire Now ) of each profile. 我正在抓取一个网站Justdial,我需要单击每个配置文件的每个按钮( 立即查询 )。 I tried below code also but it shows ElementClickInterceptedException. 我也尝试了下面的代码,但它显示了ElementClickInterceptedException。

browser.driver.find_element_by_class_name("green-btn").first.click()

I attached the image for a reference and the source code also. 我附上了图像以供参考,并附带了源代码。

enter image description here 在此处输入图片说明

below is the inspect element code- 以下是检查元素代码-

<li class="book-btn">
<!-- <span class="dtsbtntxt">Book a Table</span> -->
<!--  <span class="inner_spr in_po"></span> -->
                       <!-- <a title="Book Doctor Appointment" class="bookap green-btn result_loader_3 big_dn" href="javascript:void(0);" onClick="showloader('result', 'result_loader_3', this); _ct('DBookAppointment', 'lspg', '2'); openDiv('best_deal_div', 'bestdeal', '', '9999PX744.X744.130617175155.L7U9', 5);"><i id="result_loader_3"></i>Enquire Now</a> -->
                                                                                                                                                            <a class="green-btn result_loader_3  wdb" onclick="_ct('gtlp', 'lspg'); showloader('result', 'result_loader_3', this); trackEvent('Get The Lowest Price', 'onclicklowestprice', 'Get The Lowest Price');  return openDiv('best_deal_div', 'bestdeal', '', '9999PX744.X744.130617175155.L7U9', 5);" href="javascript:void(0);"><i id="result_loader_3"></i>Enquire Now</a>
                                                                            <span flg="2" docid="9999PX744_X744_130617175155_L7U9" countvalue="0">

Please help, how to click on each of this button using selenium web driver, I am using chrome web driver. 请帮助,如何使用Selenium Web驱动程序单击每个按钮,我正在使用chrome Web驱动程序。

To click on Enquire Now button induce WebDriverWait and element_to_be_clickable () and the using following locator. 要单击Enquire Now按钮,请诱导WebDriverWaitelement_to_be_clickable ()以及使用以下定位器。

WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//a[contains(@class,'green-btn')][contains(.,'Enquire Now')]"))).click()

You need to import followings to exeute above code. 您需要导入以下内容以执行上述代码。

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用python在Selenium Web驱动程序中等待用户单击按钮? - How to wait for a button to be clicked by user in Selenium web-driver using python? 在 for 循环中运行 3 个变量 python selenium 网络驱动程序以打印包括链接在内的所有数据 - run 3 variables in for loop python selenium web-driver to print all data including links 我如何在Selenium Web驱动程序python中使用多线程进行Web爬网 - how can i use multi-threading for web-crawling in selenium web-driver python 无法使用Selenium Web驱动程序python从自动完成下拉列表中选择多个选项 - Unable to select multiple options from autocomplete drop-down using selenium web-driver python Selenium Web驱动程序自动化无法正常工作 - Selenium Web-driver automation not working properly 如何使用Selenium Web驱动程序和python单击导航栏? - How to click on navigation bar using selenium web driver with python? 如何使用Selenium Web驱动程序和python作为脚本语言单击图像 - how to click on an image using selenium web driver and python as scripting language 如何在 Z23EEEB4347BDD755BFC6B7EE9A 中使用 selenium firefox 和 chrome 驱动程序翻译 web 页面? - How to translate a web page using selenium firefox and chrome driver in python? 如何使用python和selenium IDE获取网页上的所有链接 - How to get all links on a web page using python and selenium IDE 我如何使用Selenium Web驱动程序以正常方式打开Firefox(没有“地址无效”屏幕) - How do I Open Firefox in a normal way(with out “The address isn't valid” screen) using selenium web-driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM