得益于pythonista3的优良特性,同时支持widget显示
所以我写了一个python脚本用于检测小说更新并在widget里显示(同时追四五个小说,每次都打开看更新太麻烦了)
#!python3
import appex, ui
import clipboard
import urllib.request
import re
import threading
def main():
v = ui.View(frame=(0, 0, 320,220))#0.0.320.320
label = ui.Label(frame=(8, 0, 320 - 44 - 8, 220), flex='wh')#wh
label.name = 'text_label'
label.font = ('Menlo', 18)
label.number_of_lines = 0
v.add_subview(label)
appex.set_widget_view(v)
NovelScan()
label.text = novel_print["novel_1"]+"\n\t\t\t\t"+novel_txt["novel_1"]+"\n"+novel_print["novel_2"]+"\n\t\t\t\t"+novel_txt["novel_2"]+"\n"+novel_print["novel_3"]+"\n\t\t\t\t"+novel_txt["novel_3"]+"\n"+novel_print["novel_4"]+"\n\t\t\t\t"+novel_txt["novel_4"]
def NovelScan():
time=''
for time in novel_scan:
response=urllib.request.urlopen(novel_scan[time])
html=response.read()
text=str(html,'utf-8')
new=re.findall(r'''第.*?(?=" target="_blank">)''', text)
new_str=str(new)
novel_txt[time]=new_str[2:len(new_str)-2]
if __name__ == '__main__':
novel_scan = {
"novel_1" : 'http://book.qidian.com/info/2750457',#大主宰
"novel_2" : 'http://book.qidian.com/info/3542109',#茅山捉鬼人
"novel_3" : 'http://book.qidian.com/info/3513193',#雪鹰领主
"novel_4" : 'http://book.qidian.com/info/1931432'#校花的贴身高手
}
novel_print = {
"novel_1" : '大主宰最新章节',
"novel_2" : '茅山捉鬼人最新章节',
"novel_3" : '雪鹰领主最新章节',
"novel_4" : '校花的贴身高手最新章节'
}
novel_txt ={
"novel_1" : '',
"novel_2" : '',
"novel_3" : '',
"novel_4" : ''
}
main()
这是我的程序,目前还在优化中,在电脑上通过multiprocessing库可以做到两秒检测所有小说,但是ios不支持多进程查询,目前正在尝试加快搜索速度
现在的效果如图
有赞就更新