python requests

import requests
rr=requests.get("https://api.github.com",auth=('user','pass'))
print(rr.status_code)
print(rr.headers['content-type'])

结果:

===================== RESTART: D:/Python/Python37/re5.py =====================
403
application/json; charset=utf-8
>>>

headers={'User-Agent':'   ',}

html=requests.get(url,headers=headers)

html.encoding='utf-8'

 

data={'entities_only':'true','page':'1'}
htmla=requests.post(url,data=data)

#提示:如果网页有“更多”按钮,但网址不变。打开F12,点“更多”,出现,分析:有post:有新网址及fordata

 

 

 

 

import sys

reload(sys)

sys.setdefaultencoding("utf-8")

强制转换utf-8

你可能感兴趣的:(python requests)