Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
crawler
Commits
5f2ac9ce
Commit
5f2ac9ce
authored
Aug 20, 2021
by
李小芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4309e098
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
hospital.py
dev/xinyang_ask_tag/hospital.py
+16
-16
No files found.
dev/xinyang_ask_tag/hospital.py
View file @
5f2ac9ce
...
...
@@ -111,7 +111,6 @@ class SoYoung(object):
def
search
(
self
,
page
=
0
):
try
:
# 每次请求之前先暂停几秒 防止被ban
s
=
random
.
random
()
time
.
sleep
(
s
)
self
.
headers
[
"page"
]
=
page
...
...
@@ -120,6 +119,7 @@ class SoYoung(object):
response
=
json
.
loads
(
response_res
.
text
)
return
response
elif
response_res
.
status_code
==
403
:
time
.
sleep
(
30
)
return
self
.
search
()
else
:
print
(
"列表请求发生错误,停止请求"
)
...
...
@@ -201,7 +201,6 @@ class SoYoung(object):
return
{},
{}
if
__name__
==
'__main__'
:
soyoung
=
SoYoung
()
hospital_red_bag
=
{}
...
...
@@ -213,17 +212,18 @@ if __name__ == '__main__':
print
(
all_hospital_shangwu_info
)
# f = open("医院尾款劵数据.csv", "a+", encoding="utf-8")
# csv_writer = csv.writer(f)
# # csv_writer.writerow(
# # ["大区", "城市", "商务", "机构名称", "满", "减", "劣势/缺失", "到期时间", "查到劣势日期", "最晚补券时间"])
#
# for i in range(1, 2):
# hospital_red_bag, city_info = soyoung.response_analysis(page=i, have_get_hospital_id=have_get_hospital_id)
# for name, value in hospital_red_bag.items():
# for item in value:
# csv_writer.writerow(["", city_info[name], "", name, item.get("红包满减"), item.get("红包金额"), "",
# item.get("到期时间"),
# time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), ""])
# print("have_get_hospital_id:", have_get_hospital_id)
# print(hospital_red_bag)
f
=
open
(
"医院尾款劵数据.csv"
,
"a+"
,
encoding
=
"utf-8"
)
csv_writer
=
csv
.
writer
(
f
)
# csv_writer.writerow(
# ["大区", "城市", "商务", "机构名称", "满", "减", "劣势/缺失", "到期时间", "查到劣势日期", "最晚补券时间"])
#page
for
i
in
range
(
1
,
2
):
hospital_red_bag
,
city_info
=
soyoung
.
response_analysis
(
page
=
i
,
have_get_hospital_id
=
have_get_hospital_id
)
for
name
,
value
in
hospital_red_bag
.
items
():
for
item
in
value
:
csv_writer
.
writerow
([
""
,
city_info
[
name
],
""
,
name
,
item
.
get
(
"红包满减"
),
item
.
get
(
"红包金额"
),
""
,
item
.
get
(
"到期时间"
),
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
()),
""
])
print
(
"have_get_hospital_id:"
,
have_get_hospital_id
)
print
(
hospital_red_bag
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment