(1)先注册网站账号,后登陆。
(2)requests 自动管理headers和proxies, session保持连接,代码如下:
#-*- coding: utf-8 -*-
import requests
session = requests.session()
session.headers= {
'User-Agent':'XXX',
'Cookie':'XXX'
}
session.proxies
= {
"http":"http://127.0.0.1:16823",
"https":"http://127.0.0.1:16823
}
def get_content0(url0):
response0= session.get(url0)
content0= response0.text
time.sleep(2)
return content0