add argument,focus
This commit is contained in:
parent
cb352e489e
commit
bafae1ed30
97
chaine.json
97
chaine.json
@ -199,6 +199,33 @@
|
||||
"292": "Canal VOD",
|
||||
"293": "MyTF1",
|
||||
"294": "6play M6",
|
||||
"301": "TF1",
|
||||
"302": "France 2",
|
||||
"303": "France 3 National",
|
||||
"304": "CANAL+",
|
||||
"305": "France 5",
|
||||
"306": "M6",
|
||||
"307": "Arte",
|
||||
"308": "C8",
|
||||
"309": "W9",
|
||||
"310": "TMC",
|
||||
"311": "NT1",
|
||||
"312": "NRJ 12",
|
||||
"313": "LCP",
|
||||
"314": "France 4",
|
||||
"315": "BFM TV",
|
||||
"316": "CNEWS",
|
||||
"317": "CSTAR",
|
||||
"318": "Gulli",
|
||||
"319": "France \u00d4",
|
||||
"320": "HD1",
|
||||
"321": "L'\u00c9quipe",
|
||||
"322": "6ter",
|
||||
"323": "Num\u00e9ro 23",
|
||||
"324": "RMC D\u00e9couverte",
|
||||
"325": "Ch\u00e9rie 25",
|
||||
"326": "LCI",
|
||||
"327": "France Info",
|
||||
"350": "France 3 Alpes",
|
||||
"351": "France 3 Alsace",
|
||||
"352": "France 3 Aquitaine",
|
||||
@ -287,6 +314,76 @@
|
||||
"474": "RT",
|
||||
"475": "TRT T\u00fcrk",
|
||||
"476": null,
|
||||
"500": "TF1",
|
||||
"501": "France 2",
|
||||
"503": "Canal+",
|
||||
"504": "M6",
|
||||
"505": "Arte",
|
||||
"506": "Canal+ Cin\u00e9ma",
|
||||
"507": "Canal+ Sport",
|
||||
"508": "Canal+ S\u00e9ries",
|
||||
"509": "Canal+ Family",
|
||||
"510": "Canal+ D\u00e9cal\u00e9",
|
||||
"512": "Cin\u00e9+ Premier",
|
||||
"513": "Cin\u00e9+ Frisson",
|
||||
"514": "Cin\u00e9+ \u00c9motion",
|
||||
"516": "Paramount Channel",
|
||||
"517": "TCM Cin\u00e9ma",
|
||||
"518": "OCS Max",
|
||||
"519": "OCS City",
|
||||
"520": "OCS Choc",
|
||||
"521": "OCS G\u00e9ants",
|
||||
"522": "SundanceTV",
|
||||
"523": "Action",
|
||||
"524": "Disney Cinema",
|
||||
"525": "serieclub",
|
||||
"530": "Elle Girl",
|
||||
"531": "MTV",
|
||||
"532": "Non Stop People",
|
||||
"533": "J-One",
|
||||
"534": "T\u00e9va",
|
||||
"535": "Paris Premi\u00e8re",
|
||||
"536": "RTL9",
|
||||
"537": "C8",
|
||||
"538": "W9",
|
||||
"539": "CStar",
|
||||
"540": "HD1",
|
||||
"541": "6ter",
|
||||
"542": "Num\u00e9ro 23",
|
||||
"543": "Ch\u00e9rie 25",
|
||||
"544": "TV5 Monde FBS",
|
||||
"546": "Plan\u00e8te+",
|
||||
"552": "National Geographic",
|
||||
"553": "Nat Geo Wild",
|
||||
"554": "Voyage",
|
||||
"555": "Ushua\u00efa TV",
|
||||
"557": "Animaux",
|
||||
"558": "RMC D\u00e9couverte",
|
||||
"559": "CNews",
|
||||
"560": "BFM TV",
|
||||
"561": "BFM Business",
|
||||
"562": "Eurosport 1",
|
||||
"563": "Eurosport 2",
|
||||
"565": "AB Moteurs",
|
||||
"567": "Equidia",
|
||||
"569": "beIN Sports 1",
|
||||
"570": "beIN Sports 2",
|
||||
"571": "beIN Sports 3",
|
||||
"572": "Golf+",
|
||||
"573": "L'\u00c9quipe",
|
||||
"578": "Disney Channel",
|
||||
"579": "Disney XD",
|
||||
"580": "Disney Junior",
|
||||
"581": "Cartoon Network",
|
||||
"582": "Canal J",
|
||||
"583": "Nickelodeon Teen",
|
||||
"590": "Stingray Brava",
|
||||
"591": "M6 Music",
|
||||
"592": "Mezzo Live HD",
|
||||
"593": "Stingray Djazz",
|
||||
"596": "MTV Hits",
|
||||
"598": "A+",
|
||||
"599": "Penthouse HD",
|
||||
"600": "France Culture",
|
||||
"601": "France Musique",
|
||||
"602": "FIP",
|
||||
|
58
chaineTV.py
58
chaineTV.py
@ -4,12 +4,15 @@ from tkinter import *
|
||||
from bs4 import BeautifulSoup
|
||||
import urllib.request
|
||||
import json
|
||||
import sys
|
||||
|
||||
def click ():
|
||||
print (value.get())
|
||||
try:
|
||||
label2["text"]+=data[value.get()]+"\r"
|
||||
print(data[value.get()])
|
||||
except KeyError:
|
||||
print ("numero de chaine inconnue")
|
||||
label2["text"]+="numero de chaine inconnue"+"\r"
|
||||
|
||||
|
||||
@ -25,23 +28,76 @@ def load_jsonfile(file):
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
def RepresentsInt(s):
|
||||
try:
|
||||
int(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
except TypeError:
|
||||
return False
|
||||
def parsechaine():
|
||||
URL='https://fr.wikipedia.org/wiki/Liste_des_cha%C3%AEnes_de_Canal'
|
||||
liste_chaine={}
|
||||
response = urllib.request.urlopen(URL)
|
||||
html = response.read()
|
||||
parse=BeautifulSoup(html,"html.parser")
|
||||
for item in parse.find_all('table'):
|
||||
if (item.get("class") == ['wikitable'] or item.get("class") == ['wikitable', 'sortable'] ):
|
||||
for tr in item.find_all('tr'):
|
||||
|
||||
firstTD=tr.find()
|
||||
num=firstTD.string
|
||||
if RepresentsInt(num):
|
||||
#print (num)
|
||||
if RepresentsInt(firstTD.find_next().string):
|
||||
#print (firstTD.find_next().find_next().string)
|
||||
liste_chaine[num]=firstTD.find_next().find_next().string
|
||||
else:
|
||||
#print (firstTD.find_next().string)
|
||||
liste_chaine[num]=firstTD.find_next().string
|
||||
print(json.dumps(liste_chaine, indent=4))
|
||||
with open('chaine.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(liste_chaine, f, indent=4)
|
||||
data=load_jsonfile('chaine.json')
|
||||
label2["text"]+="update chaine done"+"\r"
|
||||
|
||||
def enter(evt):
|
||||
click()
|
||||
|
||||
|
||||
|
||||
|
||||
data=load_jsonfile('chaine.json')
|
||||
fenetre = Tk()
|
||||
value = StringVar()
|
||||
value.set("")
|
||||
try:
|
||||
sys.argv[1]
|
||||
value.set(sys.argv[1])
|
||||
arg=True
|
||||
except IndexError:
|
||||
value.set("")
|
||||
arg=False
|
||||
|
||||
label=Label(fenetre,text="entrer numero de chaine")
|
||||
entree = Entry(fenetre, textvariable=value, width=30)
|
||||
frame =Frame(fenetre)
|
||||
label2=Label(fenetre, text="")
|
||||
bouton_update_base= Button(fenetre,text="update la base de chaine",command=parsechaine)
|
||||
bouton=Button(frame, text="OK", command=click)
|
||||
reset=Button(frame, text="reset",command=click_reset)
|
||||
|
||||
label.pack()
|
||||
entree.pack()
|
||||
entree.focus_set()
|
||||
frame.pack()
|
||||
bouton.pack(side = LEFT)
|
||||
reset.pack(side = RIGHT)
|
||||
label2.pack()
|
||||
bouton_update_base.pack()
|
||||
fenetre.bind("<Key-Return>",enter)
|
||||
if (arg==True):
|
||||
click()
|
||||
value.set("")
|
||||
|
||||
fenetre.mainloop()
|
||||
|
@ -20,7 +20,7 @@ def parsechaine():
|
||||
html = response.read()
|
||||
parse=BeautifulSoup(html,"html.parser")
|
||||
for item in parse.find_all('table'):
|
||||
if (item.get("class") == ['wikitable', 'sortable']):
|
||||
if (item.get("class") == ['wikitable'] or item.get("class") == ['wikitable', 'sortable'] ):
|
||||
for tr in item.find_all('tr'):
|
||||
|
||||
firstTD=tr.find()
|
||||
@ -41,5 +41,6 @@ def load_jsonfile(file):
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
parsechaine()
|
||||
data=load_jsonfile('chaine.json')
|
||||
print(data["0"])
|
Loading…
Reference in New Issue
Block a user