新建proxy_list.txt文本,一行一个ip代理ip地址,必要情况下可以加上端口号
import requests
url = 'www.920vip.net'
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
}
# 读取ip代理池
with open('proxy_list.txt', 'r') as f:
while True:
for line in f.readlines():
proxy = line.strip('n') # 删除每一行最后面的换行符
print(proxy)
proxy_support = {
'http': 'http://' + proxy
}
response = requests.get(url, proxies=proxy_support)
print(response.text)
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net