-2
enter image description here如何获得与蟒蛇硒CSS伪元素含量
我怎么能找到使用硒伪元素? 我想要的输出是地址“http://www.meishij.net/alldish.php?id=1799616”。
enter image description here如何获得与蟒蛇硒CSS伪元素含量
我怎么能找到使用硒伪元素? 我想要的输出是地址“http://www.meishij.net/alldish.php?id=1799616”。
为什么不BeautifulSoup
尝试:
import requests
from bs4 import BeautifulSoup
pages = requests.get('http://www.meishij.net/zuofa/qingjiaosansi.html')
soup =BeautifulSoup(pages.content, 'html.parser')
result = soup.find('a',{'title':"青椒三丝"}).get('href')
print(result)
result
将是:
http://www.meishij.net/alldish.php?id=1799616
你并不需要找到伪元素(反正这是不可能的,因为::after
不是的一部分DOM
)。简单地尝试
link = driver.find_element_by_xpath("//a[@title='青椒三丝']").get_attribute("href")
获得所需的链接
欢迎#1,请编辑您的帖子和图片链接/标签前放置一个'!'(惊叹号)内嵌的图像。还请提供一些你认为是什么伪元素的背景,以及为什么要选择它?你想测试什么元素? –
欢迎来到Stack Overflow!请参阅:[我如何做X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-dox )对SO的期望是,用户提出的问题不仅仅是研究来回答他们自己的问题,而且还分享研究,代码尝试和结果。这表明你已经花时间去尝试帮助自己,它使我们避免重申明显的答案,最重要的是它可以帮助你得到更具体和相关的答案!另见:[问] – JeffC