此站点:
https://int.soccerway.com/international/europe/european-championships/c25/
EUROPE
European Championship
2020
Group Stage
Final Stages
EC Qualification
WC Qualification Europe
UEFA Nations League
Baltic Cup
它在Group Stage
和Final Stages
的左侧菜单区域有两个链接:
https://int.soccerway.com/international/europe/european-championships/2020/group-stage/r38188/
https://int.soccerway.com/international/europe/european-championships/2020/s13030/final-stages/
我正在收集链接,但是当我试图一个接一个地打开页面时,它只会在第一个链接处停止,而不会打开第二个链接,我应该更改什么
url = "https://int.soccerway.com/international/europe/european-championships/c25/"
driver.get(url)
links_level_2 = driver.find_elements_by_xpath("//ul[contains(@class,'level-2')]/li/a")
for link_level_2 in links_level_2:
level_2 = link_level_2.get_attribute("href")
driver.get(level_2)
使用
beautifulsoup
可以很容易地做到这一点由于您没有清楚地提到这些
links
是什么,我假设您正在试图提取ul
下的links
,查看我们的代码下面是使用
beautifulsoup
的代码它从上面提到的两个链接获取<ul>
下的链接相关问题 更多 >
编程相关推荐