IP代理池和Cookie池简单代码

import requests

# url="http://httpbin.org/ip"
# # response=requests.get(url=url)
# # print(response.text)
# proxy={
# 	'http':'125.42.148.190:8060'
# }
# response=requests.get(url=url,proxies=proxy)
# print(response.text)

proxy的内容可以在ip代理网站上找

mport requests

url = 'http://www.renren.com/SysHome.do'
data = {"email": '[email protected]', 'password': "pythonspider"}
headers = {
    'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36"
}
session = requests.Session()
session.post(url, data=data, headers=headers)
response = session.get('http://www.renren.com/880151247/profile')
with open('renren.html', 'w', encoding='utf-8')as p:
    p.write(response.text)

主要应用了:session.post和session.get方法

你可能感兴趣的:(python爬取网站,IP代理)