Skip to content

Commit 32fb4ea

Browse files
authored
Update lagouSpider.py
修改交互时接收职位名称的字符串,使用英语替换中文出现的编码错误
1 parent 04ecaaa commit 32fb4ea

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lagouSpider.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#-*- coding:utf-8 -*-
2+
#正常爬取拉勾数据,由于编码问题,可能出现字符显示乱码。
13
import requests
24
from openpyxl import Workbook
35

@@ -9,7 +11,7 @@ def get_json(url, page, lang_name):
911
for i in list_con:
1012
info = []
1113
info.append(i['companyShortName'])
12-
info.append(i['companyName'])
14+
#info.append(i['companyName'])
1315
info.append(i['salary'])
1416
info.append(i['city'])
1517
info.append(i['education'])
@@ -18,7 +20,7 @@ def get_json(url, page, lang_name):
1820

1921

2022
def main():
21-
lang_name = input('职位名:')
23+
lang_name = raw_input("Press the enter the job name:")
2224
page = 1
2325
url = 'http://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false'
2426
info_result = []
@@ -31,7 +33,8 @@ def main():
3133
ws1.title = lang_name
3234
for row in info_result:
3335
ws1.append(row)
34-
wb.save('职位信息.xlsx')
36+
filename = "job_info_about_"+lang_name+".xlsx"
37+
wb.save(filename)
3538

3639
if __name__ == '__main__':
3740
main()

0 commit comments

Comments
 (0)