没有伪装头,被反爬了
加个伪装头伪装成浏览器就行了
import requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'cookie': 'BIDUPSID=45588421F978DE2902A1A47464D72AB3; PSTM=1609986056; BAIDUID=45588421F978DE29E3D21BB7BB5A6873:FG=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; __yjs_duid=1_e3607a56e43709e2ca3db4147c46396a1612784778582; BAIDUID_BFESS=45588421F978DE29E3D21BB7BB5A6873:FG=1; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1614696427; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1614697139; __yjsv5_shitong=1.0_7_253e552513b2cf371866473b2e57fb4e5137_300_1614697145680_59.50.85.17_fe15699c; ab_sr=1.0.0_ZDRiZDU1NjAzNjRkMDUyOWE3ZTg3MWZlMjRhMGE4NzkwYmI3N2ExMzliMjY3MjIxOGIyY2EyMmMxNWQzOWFmY2UyZDZjMGFkYzVjNWZkNGQ1ZWIxMTJmYjZjM2Y0M2M2'
}
re = requests.get('https://api.github.com/events',headers = headers)
|