1 import requests 2 3 4 resp = requests.get("http://httpbin.org/ip") 5 print(resp.text) 6 7 proxy = { 8 'http':'60.167.102.218:9999' 9 } 10 resp2 = requests.get("http://httpbin.org/ip",proxies = proxy) 11 #运行失败的话要更换代理IP,免费的经常会有这样的问题,响应时间太久 12 print(resp2.text)
1 import requests 2 3 4 url = "http://www.renren.com/" 5 data = { 6 "email":"97013807@qq.com", 7 "password":"pythonspider" 8 } 9 headers = {} 10 session = requests.Session() 11 session.post(url,data=data,headers = headers) 12 13 resp = session.get(url)