def
parse(url, params):
res
=
requests.get(url, headers
=
headers, params
=
params, proxies
=
proxies)
try
:
if
len
(res.json())
=
=
0
:
return
for
item
in
res.json():
data
=
{
"title"
: item[
"title"
],
"release_date"
: item[
"release_date"
],
"cover_url"
: item[
"cover_url"
],
"url"
: item[
"url"
],
"score"
: item[
"score"
],
"types"
: item[
"types"
],
"rank"
: item[
"rank"
],
"actors"
: item[
"actors"
],
"regions"
: item[
"regions"
],
"actor_count"
: item[
"actor_count"
],
"vote_count"
: item[
"vote_count"
]
}
res
=
col.insert_one(data)
print
(res.inserted_id)
params_next
=
{
'type'
:
"11"
,
'interval_id'
:
'100:90'
,
'action'
: "",
'start'
:
str
(
int
(params[
"start"
])
+
20
),
'limit'
:
"20"
}
parse(url, params_next)
except
:
print
(
"this data is empty"
)
parse(url, params_next)