这个代码忘了是aar群里谁发的, 抛开他采集的东西不说, 这个代码还是值得学习的,
import win.ui;
import fonts.fontAwesome;
/*DSG{{*/
var uvform = win.form(text="aardio form";right=719;bottom=375;bgcolor=0;border="none";exmode="none";mode="popup")
uvform.add(
listview={cls="listview";left=0;top=0;right=720;bottom=344;aw=1;bgcolor=0;border=1;color=16777215;edge=1;font=LOGFONT(h=-19);gridLines=1;vscroll=1;z=3};
plus={cls="plus";text='\uF0E2更新';left=320;top=344;right=400;bottom=376;color=16777215;font=LOGFONT(h=-19;name='FontAwesome');notify=1;z=1};
plus2={cls="plus";text='\uF00D关闭';left=456;top=344;right=520;bottom=376;color=16777215;font=LOGFONT(h=-19;name='FontAwesome');notify=1;z=2}
)
/*}}*/
//灵感来自http://www.htmlayout.cn/t/228(分享一个播放.m3u8后缀网络视频的软件),可以加入aPlayer,采集后直接播放
import style.player;
import fsys.ini
var uv33ini=fsys.ini("\playlist\33uv.ini")
uvform.plus.skin(style.player.stop);
uvform.plus2.skin(style.player.stop);
uvform.listview.insertColumn("序号",50);
uvform.listview.insertColumn("电影名称",150);
uvform.listview.insertColumn("电影地址",415);
uvform.listview.insertColumn("更新日期",100);
var updatebox=function(){
var secs=uv33ini.getSectionNames();
for(i=1;#secs;1){
var item_table={i;secs[i];uv33ini.read(secs[i],"Url");uv33ini.read(secs[i],"Updated")};
uvform.listview.addItem(item_table,i);
}
}
updatebox();
pyCode=/*
import aardio
import requests
from urllib.parse import urljoin
import os,time,random
from lxml import etree
from time import sleep
#import configparser
#returnRes=[]
def rand_header(ref_url):
user_agent_list = [ \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1" \
"Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6", \
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/19.77.34.5 Safari/537.1", \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5", \
"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.36 Safari/536.5", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.0 Safari/536.3", \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24", \
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"
]
ua = random.choice(user_agent_list)
headers = {'User-Agent': ua, "Referer": ref_url}
return headers
def xtr(url):
header=rand_header(url)
resp_content=requests.get(url,headers=header).content
sleep(1)#防止太快,也没做异常处理
return etree.HTML(resp_content)
start_url='http://156zy.co/?m=vod-type-id-16.html'
def go(url):
print('Let\'s Go...,Have a cup of coffee')
#tempRes=[]
#config=configparser.ConfigParser()
for i in range(1,7):#此处控制页面数,默认1-6
if i==1:
url_0=url
else:
url_0="http://156zy.co/?m=vod-type-id-16-pg-{}.html".format(i)
xpa=xtr(url_0)
items_url=xpa.xpath("//div[@class='xing_vb']/ul/li/span/a/@href")
items_url=[urljoin('http://156zy.co/?m=vod-type-id-16.html',x) for x in items_url]
for url in items_url:
xpa0=xtr(url)
subName=xpa0.xpath("//div[@class='vodh']/h2/text()")
subUpdate=xpa0.xpath("//div[@class='vodinfobox']/ul/li[8]/span/text()")
subUrls=xpa0.xpath("//li/input/@value")
aardio.write2ini(subName[0],"Url",subUrls[1])
aardio.write2ini(subName[0],"Updated",subUpdate[0])
#tempRes.append([subName[0],subUrls[0],subUpdate[0]])
#config.add_section(subName[0])
#config.set(subName[0],"Url",subUrls[1]+"#"+subUrls[0])
#config.set(subName[0],"Update",subUpdate[0])
break#注销此语句,将更新6页
#config.write(open("./playlist/33uv.ini","w",encoding="utf-8") )
print('Well Done')
#return tempRes
returnRes=go(start_url)
*/
uvform.plus.oncommand = function(id,event){
import console;
console.setTitle("获取信息中....耐心等待")
import py; //导入py之前,要打开console,这样python的print才有效
py.appendPath("\res\Lib\site-packages\") //要将额外的requests,urllib3和lxml库文件放到该目录,发布后也需要放。
//注意对应的库版本,可以从网上直接下载对应版本的whl文件,解压然后拷贝过去。
//更新开始后不就,程序好像会卡住,不知道是不是PY导致的。可以另外单独做成一个更新程序
py.export.aardio ={
write2ini = function(s,k,u){
uv33ini.write(s,k,u);
}
}
py.exec(pyCode)
console.close();
//console.pause(true)
updatebox()
}
uvform.plus2.oncommand = function(id,event){
uvform.close();
}
uvform.show();
win.loopMessage();
return uvform;