首先要注冊一個(gè)賬號(hào)密碼,通過賬號(hào)密碼登錄,并且滑塊驗(yàn)證,自動(dòng)輸入搜索關(guān)鍵詞,進(jìn)行跳轉(zhuǎn)翻頁爬取數(shù)據(jù),并保存到Excel文件中。
代碼運(yùn)行時(shí),滑塊驗(yàn)證經(jīng)常不通過,被吃掉,但是發(fā)現(xiàn)打包成exe運(yùn)行沒有這個(gè)問題,100%成功登錄。如果大家知道這個(gè)問題麻煩請與我分享,謝謝!
廢話不多說直接上代碼
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
# coding=utf-8 from selenium import webdriver import time from PIL import Image, ImageGrab from io import BytesIO from selenium.webdriver.common.action_chains import ActionChains import os import sys import re import xlwt import urllib import datetime ''' 用于天眼查自動(dòng)登錄,解決滑塊驗(yàn)證問題 ''' # 獲取項(xiàng)目根目錄 def app_path(): if hasattr (sys, 'frozen' ): return os.path.dirname(os.path.dirname(os.path.dirname(sys.executable))) #使用pyinstaller打包后的exe目錄 return os.path.dirname(__file__) app_path = app_path() ready_list = [] #設(shè)置表格樣式 def set_style(name,height,bold = False ): style = xlwt.XFStyle() font = xlwt.Font() font.name = name # font.bold = bold font.color_index = 4 font.height = height style.font = font return style # 寫excel f = xlwt.Workbook() sheet1 = f.add_sheet( '企查查數(shù)據(jù)' ,cell_overwrite_ok = True ) row0 = [ "企業(yè)名稱" , "法定代表人" , "注冊資本" , "成立日期" , "電話" , "郵箱" , "地址" ] for i in range ( 0 , len (row0)): sheet1.write( 0 , i, row0[i], set_style( 'Times New Roman' , 220 , True )) # 寫列 def write_col(data, row, col): for i in range ( 0 , len (data)): sheet1.write(row,col,data[i],set_style( 'Times New Roman' , 220 , True )) row = row + 1 def parse_save_data(all_list): row = 1 for data in all_list: # 公司名稱 name_list = re.findall(r '<div class="info">(.*?)</div>' ,data) print (name_list) # 標(biāo)簽 tag_list = re.findall(r '<div class="tag-list">(.*)</div><div class="info row text-ellipsis">' , data) tags = [] for list in tag_list: tag = re.findall(r '<div class="tag-common -primary -new">(.*?)</div>' , list ) tags.append(tag) # print(tags) # 法定代表人 legal_list = re.findall(r '<a id="codetool">
打包成exe(注意site-packages要換成自己python包的目錄)
最終運(yùn)行dist目錄下的exe
注意事項(xiàng) 由于天眼查沒有開會(huì)員只能查看到4頁內(nèi)容,所以需要開會(huì)員,這個(gè)想要繞過就需要另外去研究,畢竟是要充錢付費(fèi),破解也沒那么簡單 到此這篇關(guān)于Python自動(dòng)化爬取天眼查數(shù)據(jù)的文章就介紹到這了,更多相關(guān)Python自動(dòng)化爬取天眼查數(shù)據(jù)內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家! 原文鏈接:https://blog.csdn.net/qq_36767214/article/details/117843296 延伸 · 閱讀
精彩推薦
|