-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_hot.py
31 lines (24 loc) · 870 Bytes
/
ck_hot.py
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
from pyspider.libs.base_handler import *
import ck_video
class HotHandler(BaseHandler):
crawl_config = {
}
p = 1
@every(seconds=2)
def on_start(self):
self.crawl('https://app.vmovier.com/apiv3/post/getPostByTab?p=' + str(self.p) + "&size=10&tab=hot",
callback=self.index_page)
self.p = self.p + 1
@config(age=0)
def index_page(self, response):
url = 'https://app.vmovier.com/apiv3/post/view?postid='
data = response.json['data']
if any(data):
for each in response.json['data']:
self.crawl(url + str(each['postid']), callback=self.detail_page, validate_cert=False)
else:
# 重新读取接口数据
self.p = 1
@config(priority=2)
def detail_page(self, response):
ck_video.handle(response.json['data'])