Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用SeleniumWeb驱动程序python单击网页中目录列表的不同链接_Python_Selenium_Selenium Webdriver_Web Scraping_Beautifulsoup - Fatal编程技术网

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

如何使用SeleniumWeb驱动程序python单击网页中目录列表的不同链接,python,selenium,selenium-webdriver,web-scraping,beautifulsoup,Python,Selenium,Selenium Webdriver,Web Scraping,Beautifulsoup,我正在抓取一个网站justdial,在那里我需要点击每个按钮,现在查询每个个人资料。我也尝试了下面的代码,但它显示ElementClickInterceptedException browser.driver.find_element_by_class_name("green-btn").first.click() 我附上了一个参考图像和源代码也 以下是检查元件代码- <li class="book-btn"> <!-- <span class="dtsbtntxt"

我正在抓取一个网站justdial,在那里我需要点击每个按钮,现在查询每个个人资料。我也尝试了下面的代码,但它显示ElementClickInterceptedException

browser.driver.find_element_by_class_name("green-btn").first.click()
我附上了一个参考图像和源代码也

以下是检查元件代码-

<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">

请帮助,如何使用selenium web驱动程序单击每个按钮,我使用的是chrome web驱动程序。

要单击“立即查询”按钮,请使用以下定位器诱导WebDriverWait和element可单击

WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//a[contains(@class,'green-btn')][contains(.,'Enquire Now')]"))).click()
您需要导入以下内容来验证上述代码

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

不要发布图片,因为它们通常没有用处。你能分享实际的网址吗?如果你这样做,你会得到更多的回应/帮助。第二,你到底想要什么?你可能不需要点击按钮就可以得到你想要的东西,但如果不提供示例输出,我们就不知道你想做什么。事实上,我现在想通过文本查询点击每个按钮。下面的操作系统的网址-感谢答复,但有n个按钮,类-绿色btn和文本-查询现在,我想这段代码将在同一时间点击所有查询按钮,但我们的要求是执行一个接一个的点击,根据清单。