-
Notifications
You must be signed in to change notification settings - Fork 6
/
task_hot.py
executable file
·41 lines (37 loc) · 1.48 KB
/
task_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
32
33
34
35
36
37
38
39
40
41
# import youran
# from youran import db,net
# URL='hot/b56ebee355d35de0_0.html?type=grab'
# mblogs=list(db.hotid.find({'url':URL+'?type=grab'}))
# print(mblogs)
# print(list(db.hotid.find({})))
# import threading
import youran
from youran import db,net,utils
from youran.db import *
from youran.net import *
# import os,logging,time
while True:
try:
# if True:
text_herfs=net.hot.get()
items=[(hot[0],hot[1]) for hot in text_herfs]
if db.hot.add({'items':items}):
# logger.warning('更新当前热点成功:')
youran.logger.warning(items)
for text,herf in text_herfs:
url,bids=net.hot.get_detail(herf)
youran.logger.warning(f'热点链接:{url},bids:{bids}')
if bids:
db.hotid.add({'url':url,'bids':bids})
for bid in bids:
if bid:
# utils.download_mblog(mblog,current_page,total_page,duplicate=duplicate,cookie=cookie,proxy=proxy)
CODE,tag=youran.utils.download_mblog(mblog={'bid':bid,'isLongText':True},cookie=True,proxy=False)
if CODE==99:#存在且设定策略为不重复,目的是节省时间
continue
else:
youran.utils.sleep(5, 10)
youran.utils.sleep(10*60,30*60)
except Exception as e:
youran.logger.error('遇到异常,错误为:'+repr(e))
utils.sleep(10*60,40*60)