【发布时间】:2021-03-26 12:29:49
【问题描述】:
我是网络抓取和使用 BeautifulSoup4 的新手,所以如果我的问题很明显,我很抱歉。
我正在尝试从 Steam 获取播放时间,但 <div id="games_list_rows" style="position: relative"> 返回 None 时它应该返回很多不同的 <div class="gameListRow" id="game_730"> 里面有东西。
我曾尝试使用朋友的个人资料,他有一些游戏,因为我认为处理大量数据可能会使 BS4 忽略 div,但它始终显示 div 为空。
这是我的代码:
import bs4 as bs
import urllib.request
# Retrieve profile
profile = "chubaquin"#input("enter profile: >")
search = "https://steamcommunity.com/id/"+profile+"/games/?tab=all"
sauce = urllib.request.urlopen(search)
soup = bs.BeautifulSoup(sauce, "lxml")
a = soup.find("div", id="games_list_rows")
print(a)
Thanks for your help!
【问题讨论】:
标签: python html web-scraping beautifulsoup urllib