-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
55 lines (47 loc) · 1.93 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: gbk -*-
import json
import requests
def crawl_xdaili():
"""
»ñȡѶ´úÀí
:return: ´úÀí
"""
url = 'http://api.xdaili.cn/xdaili-api//greatRecharge/getGreatIp?spiderId=62258522ca084c20abccfb1028f6ad7e&orderno=YZ2018626596Oclk48&returnType=2&count=1'
r = requests.get(url)
if r:
result = json.loads(r.text)
proxies = result.get('RESULT')
for proxy in proxies:
# print(proxy.get('ip'))
# print(proxy.get('port'))
proxies = {
'http': 'http://' + proxy.get('ip') + ":" + proxy.get('port'),
'https': 'https://' + proxy.get('ip') + ":" + proxy.get('port')
}
print(proxies)
return proxies
cookies = {
'ASP.NET_SessionId': 'uicdf2ltejpuriu2o0toaxw0',
'Hm_lvt_83853859c7247c5b03b527894622d3fa': '1582460741,1582466325,1582631385',
'security_session_verify': '6aeb3884e3755a4f23a27d1cdb40ceef',
'security_session_mid_verify': 'f17bdf2e9756bd02e77621aba6d6258a',
'Hm_lpvt_83853859c7247c5b03b527894622d3fa': '1582637344',
}
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Referer': 'https://www.landchina.com/default.aspx?tabid=261&ComName=default&security_verify_data=313932302c31303830',
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
}
params = (
('tabid', '261'),
('ComName', 'default'),
)
proxies = crawl_xdaili()
response = requests.get('https://www.landchina.com/default.aspx?tabid=261&ComName=default', headers=headers,
params=params, cookies=cookies, proxies=proxies, timeout=10)
print(response.status_code)