# - *-coding:utf-8-*-from Tkinter import *from ScrolledText import ScrolledText #滚动文本框import urllib,reurl_name=[]a=1def get(id): global a url=‘http://www.budejie.com/video/‘+str(a) varl.set(‘已经获取到第%s页的视频‘%(a)) a+=1 print url html = urllib.urlopen(url).read() reg=re.compile(r‘data-mp4="(.*?)"‘) vedio=re.findall(reg,html) regl=re.compile(r‘<div class="j-r-list-c-desc">(.*?)</div>‘,re.S) name=re.findall(regl,html) for i,k in zip(name,vedio): url_name.append([i,k])id=1def write(): global id while id<100: get(id) for i in url_name: text.insert(END,str(id)+‘.‘+i[0]+‘\n‘+i[1]) url_name.pop(0) id+=1root = Tk()root.title(‘我的小盒子‘)root.geometry(‘+600+100‘)text=ScrolledText(root,font=(‘微软雅黑‘,10))text.grid()button=Button(root,text="开始爬取",font=(‘黑体‘,10),command=write)button.grid()varl=StringVar()label= Label(root,font=(‘黑体‘,10),fg=‘red‘,textvariable=varl)label.grid()varl.set(‘准备中..‘) root.mainloop()
时间: 2024-10-14 01:39:29