高考分数爬到503的解决方法
重点:当遭遇503错误的时候多数是因为headers错误,出了User-Agent再加一个Accept-Encoding就可以了
import requests url="https://api.eol.cn/gkcx/api/?access_token=&page=1&province_id=33&signsafe=&size=20&uri=apidata/api/gk/score/proprovince&year=2020" hdr={"Accept-Encoding": "gzip, deflate, br","User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36"} lists= requests.get(url, headers=hdr) lists= lists.json() print(type(lists))