1+ import urllib .request
2+ import json
3+ # 提取json格式信息的库
4+ import jsonpath
5+ # 存取进xls文件的库
6+ import xlwt
7+
8+ n = 0
9+ myxls = xlwt .Workbook ()
10+ sheet1 = myxls .add_sheet (u'yx' , cell_overwrite_ok = True )
11+ # write(i,j,value)存取文档的首行
12+ sheet1 .write (0 , 1 , "公司名" )
13+ sheet1 .write (0 , 2 , "地区" )
14+ sheet1 .write (0 , 3 , "公司人数" )
15+ sheet1 .write (0 , 4 , "类型" )
16+ sheet1 .write (0 , 5 , "公司网站" )
17+ sheet1 .write (0 , 6 , "岗位需求" )
18+ sheet1 .write (0 , 7 , "要求毕业性质" )
19+ sheet1 .write (0 , 8 , "薪资" )
20+ sheet1 .write (0 , 9 , "工作性质" )
21+ sheet1 .write (0 , 10 , "福利" )
22+
23+ for i in range (1 , 10 ):
24+ url3 = "https://fe-api.zhaopin.com/c/i/sou?start=" + str (
25+ i * 90 ) + "&pageSize=90&cityId=530&industry=160400&workExperience=-1&education=4&companyType=-1&employmentType=-1&jobWelfareTag=-1&kw=java&kt=3&_v=0.20600649&x-zp-page-request-id=a0a5c8da8e5e455ca30312a4d85fa52d-1548559285341-380683"
26+ req = urllib .request .Request (url3 )
27+ req .add_header ("User-Agent" ,
28+ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 QIHU 360SE" )
29+ data = urllib .request .urlopen (req ).read ()
30+ data = json .loads (data )
31+ jobName = jsonpath .jsonpath (data , '$..jobName' )
32+ searchTag = jsonpath .jsonpath (data , "$..searchTag" )
33+
34+ company = jsonpath .jsonpath (data , "$..company" )
35+ companyName = jsonpath .jsonpath (data , "$..company.name" )
36+ companyPeopleNum = jsonpath .jsonpath (data , "$..company.size.name" )
37+ companyType = jsonpath .jsonpath (data , "$..company.type.name" )
38+ companyUrl = jsonpath .jsonpath (data , "$..company.url" )
39+
40+ city = jsonpath .jsonpath (data , "$..city" )
41+ cityName = jsonpath .jsonpath (data , "$..city.display" )
42+
43+ workingExp = jsonpath .jsonpath (data , "$..workingExp" )
44+ workingExpName = jsonpath .jsonpath (data , "$..workingExp.name" )
45+
46+ jobType = jsonpath .jsonpath (data , "$..jobType" )
47+ jobTypeName = jsonpath .jsonpath (data , "$..jobType.display" )
48+
49+ eduLevel = jsonpath .jsonpath (data , "$..eduLevel" )
50+ eduLevelName = jsonpath .jsonpath (data , "$..eduLevel.name" )
51+
52+ welfare = jsonpath .jsonpath (data , "$..welfare" )
53+ salary = jsonpath .jsonpath (data , "$..salary" )
54+ emplType = jsonpath .jsonpath (data , "$..emplType" )
55+ jobTag = jsonpath .jsonpath (data , "$..jobTag.searchTag" )
56+
57+ for i in range (0 , 89 ):
58+ print ("公司编号:" + str (n ))
59+ print (companyName [i ])
60+ print (cityName [i ])
61+ print (companyPeopleNum [i ])
62+ print (companyType [i ])
63+ print (companyUrl [i ])
64+ print (workingExpName [i ])
65+ # print(jobTypeName[i])
66+ print (eduLevelName [i ])
67+ # print(welfare[i])
68+ print (salary [i ])
69+ print (emplType [i ])
70+ # print(jobTag[i])
71+ print ()
72+ n = n + 1
73+ sheet1 .write (n , 0 , n )
74+ sheet1 .write (n , 1 , companyName [i ])
75+ sheet1 .write (n , 2 , cityName [i ])
76+ sheet1 .write (n , 3 , companyPeopleNum [i ])
77+ sheet1 .write (n , 4 , companyType [i ])
78+ sheet1 .write (n , 5 , companyUrl [i ])
79+ # sheet1.write(n, 6, jobTypeName[i])
80+ sheet1 .write (n , 7 , eduLevelName [i ])
81+ # sheet1.write(n,8,welfare[i])
82+ sheet1 .write (n , 8 , salary [i ])
83+ sheet1 .write (n , 9 , emplType [i ])
84+ # sheet1.write(n, 10, jobTag[i])
85+
86+ myxls .save ('yx.xls' )
0 commit comments