forked from queensun/Nyspider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8_gnxsy.py
51 lines (47 loc) · 1.38 KB
/
8_gnxsy.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
import requests
import json
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US,en;q=0.5",
'Host':'sysjk.ivdc.org.cn:8081',
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0"}
def table_page(page):
data={
'start':page*20,
'limit':20,
'condList':'',
}
html=requests.post('http://sysjk.ivdc.org.cn:8081/cx/querygnxsyzc/queryGnxsyzc.do', data=data,headers=headers).text
data=json.loads(html)['rows']
result=[]
keys=['ggh', 'byx', 'lb', 'zsh', 'yzdw', 'ggrq', 'syz', 'shr', 'gg', 'xsymc', 'bz', 'shrq', 'itemid']
for item in data:
'''
for key in item:
keys.append(key)
print(keys)
return
'''
line=[]
for key in keys:
try:
line.append(item[key])
except:
line.append('')
result.append(line)
return result
def main():
page=0
while True:
result=table_page(page)
if result==[]:
break
f=open('data/8_gnxsy.txt','a',encoding='utf-8')
for line in result:
f.write(str(line)+'\n')
f.close()
print(page,'ok')
page+=1
main()