Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.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 在子元素中找到href_Python_Selenium_Web Scraping_Beautifulsoup_Parent Child - Fatal编程技术网

Python 在子元素中找到href

Python 在子元素中找到href,python,selenium,web-scraping,beautifulsoup,parent-child,Python,Selenium,Web Scraping,Beautifulsoup,Parent Child,我已经尝试了不同的解决方案,但我无法在 谢谢您的帮助。尝试使用:- divElement.find("a", { "title" : "Details" }) 试试这个: link = soup.find('div').find('a').get('href') 这应该可以在不知道div之前的信息的情况下工作 url=[] 结果=驱动程序。通过类名称(“快速链接”)查找元素 对于结果中的res: url=res.find_element_by_tag_name(“a”).get_attrib

我已经尝试了不同的解决方案,但我无法在

谢谢您的帮助。

尝试使用:-

divElement.find("a", { "title" : "Details" })
试试这个:

link = soup.find('div').find('a').get('href')
这应该可以在不知道div之前的信息的情况下工作

url=[]
结果=驱动程序。通过类名称(“快速链接”)查找元素
对于结果中的res:
url=res.find_element_by_tag_name(“a”).get_attribute(“href”)
追加(url)
对于URL中的u:
驱动程序。获取(u)
使用以下命令:-

soup.select("div.quicklinks").find("a", title="Details")
使用.find()或.select_one()来选择元素,而不是.select(),因为.select()返回元素列表,.find()返回与条件匹配的第一个元素。