import requests
import time
import random
import re
url_test = 'http://shuidi.cn/company-fa448adbe2c4d85e55902adec6362bae.html'
url_proxy = 'http://tpv.daxiangdaili.com/ip/?tid=559307898014614&num=1&category=2&sortby=time'
# url_proxy = 'http://piping.mogumiao.com/proxy/api/get_ip_al?appKey=a7f685fff8cf479e9ed2cb654a71eccb&count=1&expiryDate=0&format=1&newLine=2'
proxies = {'http': 'http://10.2.1.229:9999', 'https': 'http://10.2.1.229:9999'}
count = 0
res = requests.get(url_proxy, proxies=proxies)
# pro_ip = re.findall('"ip":"(.*?)"}]', res.text)[0]
# pro_port = re.findall('"port":"(.*?)","ip"', res.text)[0]
# proxy = pro_ip + ':' + pro_port
proxy = res.text
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy}
# proxies = {'http': '10.2.1.229:9999'}
print(proxies)
headers = {"Connection": "keep-alive",
# "Pragma": "no-cache",
"Cache-Control": "no-cache",
"User-Agent": 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.11 TaoBrowser/2.0 Safari/536.11',
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"DNT": "1",
"Cookie": '',
"Accept-Encoding": "gzip, deflate, sdch",
"Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4",
"Referer": 'http://www.qichacha.com',
"Accept-Charset": "gb2312,gbk;q=0.7,utf-8;q=0.7,*;q=0.7"}
start = time.time()
while count < 1:
try:
# session = requests.Session()
url_test_ip = 'https://www.ip138.com/'
url_test_i = 'http://www.douban.com'
response = requests.get(url_test, headers=headers, proxies=proxies, timeout=30, verify=False)
print(requests.utils.dict_from_cookiejar(response.cookies))
print(response.text)
print('============================count:%s=======================' % count)
count += 1
# time.sleep(random.uniform(0.1, 1))
except Exception as e:
print(4)
endtime = time.time()
print('::::::::::::::%f' % (endtime-start))
网友评论