我正在获取该页面的所有链接 我只想要绿色框中带有绿色下划线的帮助类的href链接。黄色下划线是href链接
from selenium import webdriver;
webpage = "https://download.cms.gov/nppes/NPI_Files.html"
driver = webdriver.Chrome("xx\\xx\\xx\\chromedriver.exe")
driver.get(webpage)
elements = driver.find_elements_by_css_selector("li a")
for element in elements:
print(element.get_attribute("href"))
[Output] :- https://download.cms.gov/nppes/NPPES_Data_Dissemination_September_2020.zip
我将获得
pathname
属性:您可以引用标题文本,然后查找下一个元素
或
您可以使用xpath:
或者,您可以在div>;下选择一个标记;ul>;li标签(或其他内容):
这项工作:
相关问题 更多 >
编程相关推荐