簡體   English   中英

Requests 返回 Too Many Requests 狀態碼

[英]Requests returns Too Many Requests status code

目標是為帳戶頁面返回resp.text

當您運行此 function 時,您會得到響應代碼429 ,表明發出了太多請求。

即使使用 proxychains proxychains python3 file.py運行腳本,它也會返回相同的狀態代碼

文件.py

import requests

def g3t_usr(acc):
    """ Surf to account page """
    resp = requests.get(f'https://www.instagram.com/{acc}/')

    if resp.status_code == 200:
        return resp.text
    else:
        print (resp.status_code)
    
    return resp.text 
 
acc="<some_random_user>"
g3t_usr(acc)

Instagram 是否檢查 python 請求發出的請求並標記它們

嘗試在 header 中指定“用戶代理”以使您的請求更“真實”,如下所示: requests.get(f'https://www.instagram.com/{acc}/', headers={"User-Agent": "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"})

在我這邊,它起作用了,我得到了狀態碼 200。

祝您好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM