Python Beautiful Soup和urllib.request - 如何通过Steam年龄检查

问题描述 投票:1回答:1

我正在尝试制作一个Steam解析器,从一周的交易中获取信息。

但是,有些物品被年龄检查阻止。我正在使用urllib.request和Beautiful Soup 4来获取信息,但正如您可能已经猜到的那样,我无法获得M级项目。我尝试搜索类似的问题,但没有人告诉我如何使用urllib.request超过年龄检查

我希望测试只有当项目实际上没有描述时才等于'无描述'

这是我的代码:

import urllib.request

import bs4 as bs

source = urllib.request.urlopen('https://store.steampowered.com/search/?filter=weeklongdeals')
soup = bs.BeautifulSoup(source,'lxml')

searchResultContainer = soup.find('div',{'id':'search_result_container'})
containerHolder = searchResultContainer.findChildren()[1]

links = []
for a in containerHolder.findAll('a', href=True):
    links.append(a['href'])

x = 0
description = []
for link in links:
    source = urllib.request.urlopen(str(link))
    soup = bs.BeautifulSoup(source,'lxml')

    try: 
        test = soup.find('div',{'class':'game_description_snippet'}).get_text().strip()
        description.append(soup.find('div',{'class':'game_description_snippet'}).get_text().strip())
    except:
        test = 'No description'
        description.append('No description')
    finally:
        x += 1
        print(f'{x}: {test}')
python parsing beautifulsoup steam urllib3
1个回答
0
投票

我确定年龄选择保存在cookie中,因此您需要保存该cookie并将其用于您的会话。

我一般建议使用requests易于使用,应该快速,无痛。

© www.soinside.com 2019 - 2024. All rights reserved.