【问题标题】:Make Steam requests using Python via Tor通过 Tor 使用 Python 发出 Steam 请求
【发布时间】:2020-03-11 19:36:21
【问题描述】:

我的代码:

import requests
def get_tor_session():
    session = requests.session()
    session.proxies = {'http':  'socks5://127.0.0.1:9050',
                       'https': 'socks5://127.0.0.1:9050'}
    return session
session = get_tor_session()
print(session.get('https://steamcommunity.com/market/search?q=#p1_popular_desc').status_code)

状态码 429 steam 不适合我, 如果我将链接更改为 google.com,则状态码为 200。 Steam如何设置状态码200?

【问题讨论】:

  • 429 表示他们正在限制出口节点的速率,因为 Steam 从中获得了太多流量。他们也可能只是阻止爬虫。
  • 如果我使用 requests.get 而不是 session.get 那么状态码是 200,但我需要使用 tor
  • @jordanm 有很多服务器,你可以通过向主机发送User-Agent 来避免429

标签: python python-requests steam tor


【解决方案1】:
import requests

proxies = {
    'http': 'socks4://116.193.218.18:34344',
    'https': 'socks4://116.193.218.18:34344'
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'}


def Tor():
    with requests.Session() as req:
        r = req.get(
            "https://steamcommunity.com/market/search?q=#p1_popular_desc", proxies=proxies)
        return r.status_code


print(Tor())

输出:

200

【讨论】:

    猜你喜欢
    • 2022-11-26
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 2012-06-13
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多