Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.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
Python 按…查找并单击元素。。。蟒蛇硒_Python_Web Scraping_Beautifulsoup - Fatal编程技术网

Python 按…查找并单击元素。。。蟒蛇硒

Python 按…查找并单击元素。。。蟒蛇硒,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我正在尝试单击一个元素。在inspect element中,我可以看到: <a href="/sondc.phtml"><b>S</b>ondeos por territorios</a> 我不知道这是什么意思。我不知道那是不是一个中庭。你能帮我吗?如果你想点击selenium的“Sondeos por territorios”链接,这就可以了 from selenium import webdriver #this path may be d

我正在尝试单击一个元素。在inspect element中,我可以看到:

<a href="/sondc.phtml"><b>S</b>ondeos por territorios</a>
我不知道这是什么意思。我不知道那是不是一个中庭。你能帮我吗?

如果你想点击selenium的“Sondeos por territorios”链接,这就可以了

from selenium import webdriver

#this path may be different on your cpu, you need to install a browser driver
driver_loc = r'C:\chromedriver_win32\chromedriver.exe' 
url = 'http://www.ogimet.com/'

driver = webdriver.Chrome(driver_loc) 
driver.get(url)

the_link = driver.find_element_by_xpath('/html/body/table/tbody/tr[2]/td[1]/div[19]/a')
the_link.click()

您甚至还没有在代码中使用selenium。使用BeautifulSoup,您无法单击任何内容
href
是链接位置:它是您单击链接时着陆的位置
from selenium import webdriver

#this path may be different on your cpu, you need to install a browser driver
driver_loc = r'C:\chromedriver_win32\chromedriver.exe' 
url = 'http://www.ogimet.com/'

driver = webdriver.Chrome(driver_loc) 
driver.get(url)

the_link = driver.find_element_by_xpath('/html/body/table/tbody/tr[2]/td[1]/div[19]/a')
the_link.click()