首页 > 解决方案 > 浏览器代码和beautifulsoup集合不同

问题描述

我尝试解析soccerstand首页足球比赛但失败了,因为我通过BeautifulSoup获得的项目与我在浏览器中看到的项目完全不同。我的代码目前很简单:

import urllib.request
from bs4 import BeautifulSoup

with urllib.request.urlopen('https://soccerstand.com/') as response:
    url_data = response.read()

soup = BeautifulSoup(url_data, 'html.parser')
print(soup.find_all('div.event__match'))

所以我尝试了这个,但失败了。当我检查汤变量时,结果发现根本不包含这样的 div,所以我从 BS 得到的结果与我通过检查网站上的代码所看到的不同。

这是什么原因?有什么解决方法吗?

标签: pythonweb-scrapingbeautifulsoup

解决方案


推荐阅读