发布于2019-08-20 10:02 阅读(1518) 评论(0) 点赞(27) 收藏(0)
本次编写程序目的在于学习python爬虫技术入门,注意到有vip视频解析网站,于是进行编写,该程序可以跳过vip广告,或者vip5分钟时间限制。还可以保存浏览记录,十分方便。
- __author__ = 'PythonStriker'
-
- import requests
- import webbrowser
- import re
- import tkinter as tk
- from tkinter import ttk
- import os
-
- data = ["播放接口1","播放接口2",\
- "播放接口3","播放接口4",\
- "播放接口5"]
-
- url = 'http://www.qmaile.com/'
-
- def read():
- if os.path.exists('data.txt'):
- with open('data.txt', encoding='utf-8', mode='r') as file:
- if os.path.getsize('data.txt')==0:
- readlist = ['', '']
- else:
- lines = file.readlines()
- last_line = lines[-1]
- readlist = last_line.split(' ')
- else:
- file = open('data.txt',encoding='utf-8',mode='a')
- file.close()
- readlist = ['', '']
- return readlist
-
- responed = requests.get(url)
- reg = re.compile('<option value="(.*?)" selected="">')
- res = re.findall(reg,responed.text)
-
- root = tk.Tk()
- root.title('vip_movie')
- root.geometry('290x150')
- l1 = tk.Label(root,text='播放接口:',font=12).grid(row = 0,column = 0)
-
- var = tk.StringVar()
- Var = tk.StringVar()
- var.set(res[2])
- reload_url = tk.StringVar()
- reload_url.set(read()[-1])
- reload_name = tk.StringVar()
- reload_name.set(read()[0])
-
- combo = ttk.Combobox(root ,textvariable=Var)
- combo.grid(row = 0,column = 1)
- combo["values"] = data
- combo.current(0)
-
- def choice(event):
- if combo.get()=="播放接口1":
- var.set(res[0])
- elif combo.get()=="播放接口2":
- var.set(res[1])
- elif combo.get()=="播放接口3":
- var.set(res[2])
- elif combo.get()=="播放接口4":
- var.set(res[3])
- else:
- var.set(res[4])
-
- combo.bind("<<ComboboxSelected>>",choice)
- l2 = tk.Label(root,text='播放链接:',font=12).grid(row = 1,column = 0)
- e1 = tk.Entry(root ,textvariable =reload_url ,text = reload_url,width = 23 )
-
- e1.grid(row =1,column = 1)
- e2 = tk.Entry(root,text=reload_name,width = 23)
- e2.grid(row =3,column=1)
- l3 = tk.Label(root,text='链接名称',font=12).grid(row =3,column=0)
-
- def play():
- webbrowser.open(var.get()+e1.get())
-
- def save():
- with open('data.txt', encoding='utf-8', mode='a') as file:
- file.writelines([e2.get()+' ',e1.get()+'\n'])
-
- b1 = tk.Button(root, text = '播放', font = 10 ,command = play).grid(row = 2,column =1)
- b1 = tk.Button(root, text = '保存', font = 10 ,command = save).grid(row = 4,column =1)
- root.mainloop()
所用到的技术不多,一个request作用于网站接口获取,io函数用来保存浏览记录,方便下次观看。效果如下:
在播放连接内放入想要观看的vip视频链接,连接名称需要认真编写,以便于数据存储,和历史数据访问。
首次打开程序时会在同级目录下建立data.txt进行记录存储。
作者:坚持才能胜利
链接:https://www.pythonheidong.com/blog/article/48920/c2a3f445f436737ea299/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!