【发布时间】:2022-01-10 13:57:02
【问题描述】:
我正在尝试对这个webpage 进行网络报废,但我总是最终得到"main" page(相同的URL,但最后没有“#face-a-face”)。和这个人遇到的问题一样,看这个forum。他得到了答案,但我无法概括并将其应用于我要废弃的网站。
import requests
from bs4 import BeautifulSoup
url_main = "https://www.lequipe.fr/Football/match-direct/ligue-1/2020-2021/ol-dijon-live/477168"
url_target = url_main + "#face-a-face"
soup_main = BeautifulSoup(requests.get(url_main, verify=False).content, "html.parser")
soup_target = BeautifulSoup(requests.get(url_target, verify=False).content, "html.parser")
print(soup_main == soup_target)
返回True。我想得到不同的内容,这里不是这样。
例如,我想提取目标网页中的所有“confrontations depuis 2011”。如何通过 GET 请求(或其他方式)获得此 webpage 的最终内容?谢谢!
【问题讨论】:
-
该网站上有很多 JavaScript 代码。使用 Selenium 可能会更好
标签: python python-3.x web-scraping beautifulsoup python-requests