Différences entre les versions de « Utilisateur:Manonblanc »
(5 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
+ | == bot twitter bis == | ||
+ | |||
+ | #la librairie qui permet de se connecter au site | ||
+ | import mechanize | ||
+ | #la librairie qui permet d'analyser la structure html | ||
+ | import lxml.html | ||
+ | #la librairie qui permet de sélectionner une info dans la structure html | ||
+ | import cssselect | ||
+ | import random | ||
+ | import tweepy | ||
+ | |||
+ | import ssl | ||
+ | |||
+ | |||
+ | liste = [{"id":"Abzakh","name":"abzakh","sort_value":"abzakh"},{"id":"Achhame","name":"achhame(dialecte du n\\u00e9pali)","sort_value":"achhame(dialecte du nepali)"},{"id":"Aheu","name":"aheu","sort_value":"aheu"},{"id":"Aji\\u00eb","name":"aji\\u00eb","sort_value":"ajie"},{"id":"Angait\\u00e9","name":"angait\\u00e9","sort_value":"angaite"},{"id":"Ao","name":"ao","sort_value":"ao"},{"id":"Yemeni Arabic","name":"arabe y\\u00e9m\\u00e9nite ","sort_value":"arabe yemenite "},{"id":"Yemeni Arabic (Sanaa dialect)","name":"arabe y\\u00e9m\\u00e9nite (dialecte de Sanaa)","sort_value":"arabe yemenite (dialecte de Sanaa)"},{"id":"Yemeni Arabic (Zabid dialect)","name":"arabe y\\u00e9m\\u00e9nite (dialecte de Zabid)","sort_value":"arabe yemenite (dialecte de Zabid)"},{"id":"Araki","name":"araki","sort_value":"araki"},{"id":"Arem","name":"arem","sort_value":"arem"},{"id":"Badaga","name":"badaga","sort_value":"badaga"},{"id":"Bafia","name":"bafia","sort_value":"bafia"},{"id":"Bahing","name":"bahing","sort_value":"bahing"},{"id":"Baima","name":"baima","sort_value":"baima"},{"id":"Ban Houei Long dialect of Phay","name":"ban Houei Long (dialecte du phay)","sort_value":"ban Houei Long (dialecte du phay)"},{"id":"Ban Samet dialect of Phay","name":"ban Samet (dialecte du phay)","sort_value":"ban Samet (dialecte du phay)"},{"id":"Burmese","name":"birman","sort_value":"birman"},{"id":"Bislama","name":"bislama","sort_value":"bislama"},{"id":"Bjedug","name":"bjedough","sort_value":"bjedough"},{"id":"Bru","name":"bru","sort_value":"bru"},{"id":"Bulgaro-Mac\\u00e9donien","name":"bulgaro-mac\\u00e9donien","sort_value":"bulgaro-macedonien"},{"id":"Bwatoo","name":"bwatoo","sort_value":"bwatoo"},{"id":"Car-Nicobarais","name":"car-nicobarais","sort_value":"car-nicobarais"},{"id":"C\\u00e8muh\\u00ee","name":"c\\u00e8muh\\u00ee","sort_value":"cemuhi"},{"id":"Chang Naga","name":"chang naga","sort_value":"chang naga"},{"id":"Shapsug","name":"chapsough","sort_value":"chapsough"},{"id":"Chong Heup","name":"chong heup","sort_value":"chong heup"},{"id":"Chong Lo","name":"chong lo","sort_value":"chong lo"},{"id":"Chong Tratt","name":"chong tratt","sort_value":"chong tratt"},{"id":"Chrau","name":"chrau","sort_value":"chrau"},{"id":"Chru","name":"chru","sort_value":"chru"},{"id":"Croate du Burgenland","name":"croate du Burgenland","sort_value":"croate du Burgenland"},{"id":"Cu\\u1ed1i Ch\\u0103m","name":"cu\\u1ed1i ch\\u0103m","sort_value":"cuoi cham"},{"id":"Danu","name":"danu","sort_value":"danu"},{"id":"Dorig","name":"dorig","sort_value":"dorig"},{"id":"Dotyal","name":"dotyal (dialecte du n\\u00e9pali)","sort_value":"dotyal (dialecte du nepali)"},{"id":"Drehu","name":"drehu","sort_value":"drehu"},{"id":"Duoxu","name":"duoxu","sort_value":"duoxu"},{"id":"Ersu","name":"ersu","sort_value":"ersu"},{"id":"Fagauvea","name":"fagauvea","sort_value":"fagauvea"},{"id":"Futunien","name":"futunien","sort_value":"futunien"},{"id":"Ngazidja","name":"grand-comorien","sort_value":"grand-comorien"},{"id":"Ham\\u00e9a","name":"ham\\u00e9a","sort_value":"hamea"},{"id":"Hayu","name":"hayu","sort_value":"hayu"},{"id":"Hiw","name":"hiw","sort_value":"hiw"},{"id":"Iaai","name":"iaai","sort_value":"iaai"},{"id":"Inuktitut","name":"inuktitut","sort_value":"inuktitut"},{"id":"Iraqw","name":"iraqw","sort_value":"iraqw"},{"id":"Ishir","name":"ishir","sort_value":"ishir"},{"id":"Ixcatec","name":"ixcat\\u00e8que","sort_value":"ixcateque"},{"id":"Japhug","name":"japhug","sort_value":"japhug"},{"id":"Jinghpaw","name":"jinghpaw","sort_value":"jinghpaw"},{"id":"Kakabe","name":"kakabe","sort_value":"kakabe"},{"id":"Kam","name":"kam","sort_value":"kam"},{"id":"Karen","name":"karen","sort_value":"karen"},{"id":"Kha Phong","name":"kha phong","sort_value":"kha phong"},{"id":"Khaling","name":"khaling","sort_value":"khaling"},{"id":"Kh\\u00e1ng","name":"kh\\u00e1ng","sort_value":"khang"},{"id":"Cardamom Khmer","name":"khmer des Cardamomes","sort_value":"khmer des Cardamomes"},{"id":"Krom Khmer","name":"khmer krom","sort_value":"khmer krom"},{"id":"Khmu","name":"khmu","sort_value":"khmu"},{"id":"Khroskyabs","name":"khroskyabs","sort_value":"khroskyabs"},{"id":"Kh\\u00fcn","name":"kh\\u00fcn","sort_value":"khun"},{"id":"Koro","name":"koro","sort_value":"koro"},{"id":"Koyi Rai","name":"koyi rai","sort_value":"koyi rai"},{"id":"Ksing Mun","name":"ksing mun","sort_value":"ksing mun"},{"id":"Kurde central","name":"kurde","sort_value":"kurde"},{"id":"Kuy","name":"kuy","sort_value":"kuy"},{"id":"Kw\\u00eanyii","name":"kw\\u00e9ny\\u00ef\\u00ef","sort_value":"kwenyii"},{"id":"Lahu","name":"lahu","sort_value":"lahu"},{"id":"Lakon","name":"lakon","sort_value":"lakon"},{"id":"Langi","name":"langi","sort_value":"langi"},{"id":"Laven","name":"laven","sort_value":"laven"},{"id":"Laze","name":"laze","sort_value":"laze"},{"id":"Laz\\u00e9","name":"laz\\u00e9","sort_value":"laze"},{"id":"Lehali","name":"lehali","sort_value":"lehali"},{"id":"Lemerig","name":"lemerig ","sort_value":"lemerig "},{"id":"Limbu","name":"limbu","sort_value":"limbu"},{"id":"Lizu","name":"lizu","sort_value":"lizu"},{"id":"Lo-Toga","name":"lo-toga","sort_value":"lo-toga"},{"id":"Lovono","name":"lovono","sort_value":"lovono"},{"id":"L\\u00f6y\\u00f6p","name":"l\\u00f6y\\u00f6p","sort_value":"loyop"},{"id":"Lyha","name":"lyha","sort_value":"lyha"},{"id":"Lyngam (dialecte Langkma)","name":"lyngam (dialecte Langkma)","sort_value":"lyngam (dialecte Langkma)"},{"id":"Lyngam (dialecte Nongtrei)","name":"lyngam (dialecte Nongtrei)","sort_value":"lyngam (dialecte Nongtrei)"},{"id":"Maore","name":"mahorais","sort_value":"mahorais"},{"id":"Makong dialect of Bru","name":"makong (dialecte du bru\\/s\\u00f4)","sort_value":"makong (dialecte du bru\\/so)"},{"id":"Malang","name":"malang","sort_value":"malang"},{"id":"Maleng Br\\u00f4","name":"maleng br\\u00f4","sort_value":"maleng bro"},{"id":"Malieng","name":"malieng","sort_value":"malieng"},{"id":"Beijing Mandarin","name":"mandarin","sort_value":"mandarin"},{"id":"M\\u1ea3ng","name":"m\\u1ea3ng","sort_value":"mang"},{"id":"Mankon","name":"mankon","sort_value":"mankon"},{"id":"Maru","name":"maru","sort_value":"maru"},{"id":"Mbugwe","name":"mbugwe","sort_value":"mbugwe"},{"id":"Mizo","name":"mizo","sort_value":"mizo"},{"id":"Mon","name":"m\\u00f4n","sort_value":"mon"},{"id":"Mota","name":"mota","sort_value":"mota"},{"id":"M\\u01b0\\u1eddng","name":"m\\u01b0\\u1eddng","sort_value":"muong"},{"id":"Muya","name":"muya","sort_value":"muya"},{"id":"Mwerlap","name":"mwerlap","sort_value":"mwerlap"},{"id":"Mwesen","name":"mwesen","sort_value":"mwesen"},{"id":"Mwotlap","name":"mwotlap","sort_value":"mwotlap"},{"id":"Na-na\\u0161u (Acquaviva Collecroce)","name":"na-na\\u0161u (Acquaviva Collecroce)","sort_value":"na-nasu (Acquaviva Collecroce)"},{"id":"Na-na\\u0161u (San Felice del Molise)","name":"na-na\\u0161u (San Felice)","sort_value":"na-nasu (San Felice)"},{"id":"Na-na\\u0161u (Montemitro)","name":"na-na\\u0161u\\/na-na\\u0161o (Montemitro)","sort_value":"na-nasu\\/na-naso (Montemitro)"},{"id":"Namakura","name":"namakura","sort_value":"namakura"},{"id":"Nashta","name":"nashta","sort_value":"nashta"},{"id":"Naxi","name":"naxi","sort_value":"naxi"},{"id":"N\\u00eal\\u00eamwa","name":"n\\u00eal\\u00eamwa","sort_value":"nelemwa"},{"id":"Nemi","name":"nemi","sort_value":"nemi"},{"id":"Nengone","name":"nengone","sort_value":"nengone"},{"id":"Nepali","name":"n\\u00e9pali","sort_value":"nepali"},{"id":"Newar","name":"newar","sort_value":"newar"},{"id":"Nivacl\\u00e9","name":"nivacl\\u00e9","sort_value":"nivacle"},{"id":"Nume","name":"nume","sort_value":"nume"},{"id":"Num\\u00e8\\u00e8","name":"num\\u00e8\\u00e8","sort_value":"numee"},{"id":"Nyaheun","name":"nyaheun","sort_value":"nyaheun"},{"id":"Nyesam","name":"nyesam","sort_value":"nyesam"},{"id":"Nyilamba","name":"nyilamba","sort_value":"nyilamba"},{"id":"Olrat","name":"olrat","sort_value":"olrat"},{"id":"Ong","name":"ong","sort_value":"ong"},{"id":"Ubykh","name":"oubykh","sort_value":"oubykh"},{"id":"Ouldeme","name":"ould\\u00e9m\\u00e9","sort_value":"ouldeme"},{"id":"Paic\\u00ee","name":"paic\\u00ee","sort_value":"paici"},{"id":"Pakatan","name":"pakatan","sort_value":"pakatan"},{"id":"Palaong","name":"palaong","sort_value":"palaong"},{"id":"Parlanjhe","name":"parlanjhe","sort_value":"parlanjhe"},{"id":"Pear","name":"pear","sort_value":"pear"},{"id":"Phay","name":"phay","sort_value":"phay"},{"id":"Phong","name":"phong","sort_value":"phong"},{"id":"Phunoi","name":"phunoi","sort_value":"phunoi"},{"id":"Pije","name":"pije","sort_value":"pije"},{"id":"Pnar","name":"pnar","sort_value":"pnar"},{"id":"Pumi","name":"pumi","sort_value":"pumi"},{"id":"Purepecha","name":"purepecha","sort_value":"purepecha"},{"id":"Northern Qiang (Mawo dialect)","name":"qiang du nord (dialecte de Mawo)","sort_value":"qiang du nord (dialecte de Mawo)"},{"id":"Northern Qiang (Qugu dialect)","name":"qiang du nord (dialecte de qugu)","sort_value":"qiang du nord (dialecte de qugu)"},{"id":"Southern Qiang (Sanlong dialect)","name":"qiang du nord (dialecte de sanlong)","sort_value":"qiang du nord (dialecte de sanlong)"},{"id":"Northern Qiang (Shabangou dialect)","name":"qiang du nord (dialecte de shabangou)","sort_value":"qiang du nord (dialecte de shabangou)"},{"id":"Northern Qiang (Shuangliusuo dialect)","name":"qiang du nord (dialecte de shuangliusuo)","sort_value":"qiang du nord (dialecte de shuangliusuo)"},{"id":"Northern Qiang (Waboliangzi dialect)","name":"qiang du nord (dialecte de waboliangzi)","sort_value":"qiang du nord (dialecte de waboliangzi)"},{"id":"Northern Qiang (Zhawo dialect)","name":"qiang du nord (dialecte de zhawo)","sort_value":"qiang du nord (dialecte de zhawo)"},{"id":"Southern Qiang (Goukou dialect)","name":"qiang du nord (dialecte du Goukou)","sort_value":"qiang du nord (dialecte du Goukou)"},{"id":"Northern Qiang (Luoduo dialect)","name":"qiang du nord (dialecte du Luoduo)","sort_value":"qiang du nord (dialecte du Luoduo)"},{"id":"Northern Qiang (Shidiaolou dialect)","name":"qiang du nord (dialecte du Shidiaolou)","sort_value":"qiang du nord (dialecte du Shidiaolou)"},{"id":"Northern Qiang (Weicheng dialect)","name":"qiang du nord (dialecte du Weicheng)","sort_value":"qiang du nord (dialecte du Weicheng)"},{"id":"Southern Qiang (Baishui dialect)","name":"qiang du sud (dialecte du Baishui)","sort_value":"qiang du sud (dialecte du Baishui)"},{"id":"Southern Qiang (Baixi dialect)","name":"qiang du sud (dialecte du Baixi)","sort_value":"qiang du sud (dialecte du Baixi)"},{"id":"Southern Qiang (Heihu Dialect)","name":"qiang du sud (dialecte du Heihu)","sort_value":"qiang du sud (dialecte du Heihu)"},{"id":"Southern Qiang (Longxi dialect)","name":"qiang du sud (dialecte du Longxi)","sort_value":"qiang du sud (dialecte du Longxi)"},{"id":"Southern Qiang (Luobozhai Dialect)","name":"qiang du sud (dialecte du Luobozhai)","sort_value":"qiang du sud (dialecte du Luobozhai)"},{"id":"Queyu","name":"queyu","sort_value":"queyu"},{"id":"Southern Raglai","name":"raglai m\\u00e9ridional","sort_value":"raglai meridional"},{"id":"Northern Raglai","name":"raglai septentrional","sort_value":"raglai septentrional"},{"id":"Rakhine","name":"rakhine","sort_value":"rakhine"},{"id":"Rgyalrong","name":"rgyalrong","sort_value":"rgyalrong"},{"id":"Rmet","name":"rmet","sort_value":"rmet"},{"id":"Romani (Northern Vlax, Mexico)","name":"romani (vlax du nord, Mexique)","sort_value":"romani (vlax du nord, Mexique)"},{"id":"Romani (Xoraxane, Southern Vlax, Greece)","name":"romani (xoraxane, vlax du sud, Gr\\u00e8ce)","sort_value":"romani (xoraxane, vlax du sud, Grece)"},{"id":"R\\u1ee5c","name":"r\\u1ee5c","sort_value":"ruc"},{"id":"S\\u00e1ch","name":"s\\u00e1ch","sort_value":"sach"},{"id":"Saek","name":"saek","sort_value":"saek"},{"id":"Salang","name":"salang","sort_value":"salang"},{"id":"Salar","name":"salar","sort_value":"salar"},{"id":"Samre","name":"samre","sort_value":"samre"},{"id":"Senhaja de Srair (Zerqet)","name":"senhaja de Srair (Zerqet)","sort_value":"senhaja de Srair (Zerqet)"},{"id":"Situ","name":"situ","sort_value":"situ"},{"id":"Siwi","name":"siwi","sort_value":"siwi"},{"id":"Sorabe sup\\u00e9rieur (courant)","name":"sorabe sup\\u00e9rieur (courant)","sort_value":"sorabe superieur (courant)"},{"id":"Stau","name":"stau","sort_value":"stau"},{"id":"Tai Deng","name":"tai deng","sort_value":"tai deng"},{"id":"Tai Don","name":"tai don","sort_value":"tai don"},{"id":"Tai Paw","name":"tai paw","sort_value":"tai paw"},{"id":"Tai Yo","name":"tai yo","sort_value":"tai yo"},{"id":"Tamang","name":"tamang","sort_value":"tamang"},{"id":"Tampuan","name":"tampuan","sort_value":"tampuan"},{"id":"Tanema","name":"tanema","sort_value":"tanema"},{"id":"Tanimuca","name":"tanimuca","sort_value":"tanimuca"},{"id":"Tavoyan","name":"tavoyan","sort_value":"tavoyan"},{"id":"Tay Khang","name":"tay khang","sort_value":"tay khang"},{"id":"T\\u00e0y Po\\u1ecdng","name":"t\\u00e0y po\\u1ecdng","sort_value":"tay poong"},{"id":"Chechen","name":"tch\\u00e9ch\\u00e8ne","sort_value":"tchechene"},{"id":"Teanu","name":"teanu","sort_value":"teanu"},{"id":"Thaungtha","name":"thaungtha","sort_value":"thaungtha"},{"id":"Thavung","name":"thavung","sort_value":"thavung"},{"id":"Th\\u1ed5","name":"th\\u1ed5","sort_value":"tho"},{"id":"Thulung Rai","name":"thulung rai","sort_value":"thulung rai"},{"id":"Tibetan","name":"tib\\u00e9tain","sort_value":"tibetain"},{"id":"Tib\\u00e9tain de l\'Amdo","name":"tib\\u00e9tain de l\'Amdo","sort_value":"tibetain de l\'Amdo"},{"id":"Kami Tibetan","name":"tib\\u00e9tain kami","sort_value":"tibetain kami"},{"id":"Tikar","name":"tikar","sort_value":"tikar"},{"id":"Tikopia","name":"tikopia","sort_value":"tikopia"},{"id":"Tok Pisin","name":"tok pisin","sort_value":"tok pisin"},{"id":"Tomaraho","name":"tomaraho","sort_value":"tomaraho"},{"id":"Toum","name":"toum","sort_value":"toum"},{"id":"Turc de Chypre","name":"turc de Chypre","sort_value":"turc de Chypre"},{"id":"Vatlongos","name":"vatlongos","sort_value":"vatlongos"},{"id":"Vera\'a","name":"vera\'a","sort_value":"vera\'a"},{"id":"Hanoi dialect","name":"vietnamien (dialecte de Hano\\u00ef)","sort_value":"vietnamien (dialecte de Hanoi)"},{"id":"Phong Nha dialect","name":"vietnamien (dialecte de Phong Nha)","sort_value":"vietnamien (dialecte de Phong Nha)"},{"id":"Cao Lao H\\u1ea1 dialect","name":"vietnamien (dialecte du Cao Lao H\\u1ea1 )","sort_value":"vietnamien (dialecte du Cao Lao Ha )"},{"id":"Volow","name":"volow","sort_value":"volow"},{"id":"Vur\\u00ebs","name":"vur\\u00ebs","sort_value":"vures"},{"id":"Vute","name":"vute","sort_value":"vute"},{"id":"Wallisien","name":"wallisien","sort_value":"wallisien"},{"id":"War (dialecte Amwi)","name":"war (dialecte Amwi)","sort_value":"war (dialecte Amwi)"},{"id":"War (dialecte Nongtalang)","name":"war (dialecte Nongtalang)","sort_value":"war (dialecte Nongtalang)"},{"id":"War (dialecte Syndai)","name":"war (dialecte Syndai)","sort_value":"war (dialecte Syndai)"},{"id":"Wayana","name":"wayana","sort_value":"wayana"},{"id":"X\\u00e2r\\u00e2c\\u00f9\\u00f9","name":"x\\u00e2r\\u00e2c\\u00f9\\u00f9","sort_value":"xaracuu"},{"id":"X\\u00e2r\\u00e2gur\\u00e8","name":"x\\u00e2r\\u00e2gur\\u00e8","sort_value":"xaragure"},{"id":"Xumi","name":"xumi","sort_value":"xumi"},{"id":"Yongning Na","name":"yongning na","sort_value":"yongning na"},{"id":"Yucuna","name":"yucuna","sort_value":"yucuna"},{"id":"Yuanga","name":"zuanga ou yuanga","sort_value":"zuanga ou yuanga"}] | ||
+ | |||
+ | |||
+ | def getHtmlElements(url, selecteurCss): | ||
+ | #1. télécharger la source html de la page url | ||
+ | browser = mechanize.Browser() | ||
+ | browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] | ||
+ | browser.set_handle_robots(False) | ||
+ | |||
+ | #problème https | ||
+ | browser.set_ca_data(context=ssl._create_unverified_context(cert_reqs=ssl.CERT_NONE)) | ||
+ | |||
+ | data = browser.open(url, timeout=10) | ||
+ | |||
+ | '''with open("output.txt", 'w') as f: | ||
+ | f.write(str(data.read()))''' | ||
+ | |||
+ | |||
+ | #2. analyser la source et la transformer en structure html navigable | ||
+ | source = data.read() | ||
+ | #print(source) | ||
+ | |||
+ | html = lxml.html.fromstring(source.decode('utf-8')) | ||
+ | |||
+ | |||
+ | #3. viser l'information qui nous intéresse | ||
+ | |||
+ | #convertir mon sélecteur css en objet cssselect | ||
+ | selecteurs = cssselect.parse(selecteurCss) | ||
+ | #0 | ||
+ | #[objet cssselect] | ||
+ | |||
+ | selecteur = selecteurs[0] | ||
+ | |||
+ | chemin_xpath = cssselect.HTMLTranslator().selector_to_xpath(selecteur) | ||
+ | |||
+ | resultats = html.xpath(chemin_xpath) | ||
+ | |||
+ | return resultats | ||
+ | #print(resultats) | ||
+ | |||
+ | |||
+ | #1. aller chercher les liens de la liste des corpus par ordre alphabetique | ||
+ | #links = getHtmlElements('https://pangloss.cnrs.fr', '#list a') | ||
+ | |||
+ | |||
+ | print(liste[0]) | ||
+ | |||
+ | url = 'https://pangloss.cnrs.fr/corpus/'+liste[0]['id']+'?lang=fr&mode=normal' | ||
+ | |||
+ | print(url) | ||
+ | |||
+ | titre = getHtmlElements(url, 'h1') | ||
+ | |||
+ | print(titre[0].text_content()) | ||
+ | |||
+ | article = getHtmlElements(url, 'article p') | ||
+ | |||
+ | print(article[0].text_content()) | ||
+ | |||
+ | |||
+ | #for link in links: | ||
+ | # print(link.get('href')) | ||
+ | |||
+ | #goodLinks = [] | ||
+ | |||
+ | #for link in links: | ||
+ | # goodLinks.append(link.get('<a href="https://pangloss.cnrs.fr/corpus>')) | ||
+ | |||
+ | ''' | ||
+ | #2. aller chercher le nom de la langue | ||
+ | comments = getHtmlElements(link, '<h1></h1>') | ||
+ | |||
+ | message = link | ||
+ | |||
+ | print ? | ||
+ | |||
+ | #3. aller chercher un mot au hasard dans le texte de présentaion | ||
+ | |||
+ | comment = random.choice(comments) | ||
+ | |||
+ | print ? | ||
+ | |||
+ | #4. recommencer chaque jour cette action avec le lien suivant | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | #for comment in comments: | ||
+ | # print(str(comment.text_content())) | ||
+ | comment = random.choice(comments) | ||
+ | message = message + str(comment.text_content()) | ||
+ | print(message)''' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | == bot twitter == | ||
+ | |||
+ | |||
+ | Lundi à 18h bot démarre. Il annonce, il publie « C’est la semaine de (…) ». | ||
+ | (…) = une des langues présentent dans la liste des corpus de pangloss, dans l’ordre alphabétique | ||
+ | |||
+ | Mardi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | Mercredi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | Jeudi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | Vendredi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | Samedi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | Dimanche à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot. | ||
+ | |||
+ | == Exercice == | ||
+ | |||
+ | <syntaxhighlight lang="html5"> | ||
+ | <!doctype html> | ||
+ | <html> | ||
+ | <head> | ||
+ | <meta charset="utf-8"> | ||
+ | <link rel="stylesheet" href="untitled.css"> | ||
+ | </head> | ||
+ | <body> | ||
+ | |||
+ | <img id="bara1" src="bara1.JPG" alt="bara1"> | ||
+ | <img id="bara2" src="bara2.JPG" alt="bara2"> | ||
+ | <img id="bara3" src="bara3.JPG" alt="bara3"> | ||
+ | <img id="bara4" src="bara4.JPG" alt="bara4"> | ||
+ | <img id="barbe1" src="barbe1.JPG" alt="barbe1"> | ||
+ | <img id="barbe2" src="barbe2.JPG" alt="barbe2"> | ||
+ | <img id="barbe3" src="barbe3.JPG" alt="barbe3"> | ||
+ | <img id="derby1" src="derby1.JPG" alt="derby1"> | ||
+ | <img id="derby2" src="derby2.JPG" alt="derby2"> | ||
+ | <img id="derby3" src="derby3.JPG" alt="derby3"> | ||
+ | |||
+ | |||
+ | <section class="page first"> | ||
+ | |||
+ | |||
+ | |||
+ | <article> La myopie | ||
+ | _________ | ||
+ | |||
+ | Permettre un </article> voile flou sans <article> réticences, sans contraindre </article> <article> ses yeux à y voir net. </artcile> Une vision <article> nuageuse omni-constante</article> , <article> pour une existence </article> moins consciente. Moins <article> consciente </article> des lieux, moins consciente des visages, moins consciente des f </article> | ||
+ | |||
+ | </section> | ||
+ | <section class="page second"> | ||
+ | |||
+ | |||
+ | |||
+ | <p> ormes, moins consciente des lignes, moins consciente des objets, moins consciente des matériaux. Un adoucissement des contours. Un paysage où les choses se fondent entre elles sans se toucher. Lieux se confondent et espaces semblent être une seule et même chose. Les regards des au </p> | ||
+ | |||
+ | |||
+ | </section> | ||
+ | <section class="page third"> | ||
+ | |||
+ | |||
+ | <p> tres humain.e.s plus abstrait. Une chorégraphie des corps moins saccadée qui s’étale dans le temps sans discontinuer. La vue des choses est sans réponse claire. Les secrets sont gardés. Les corps rayonnants émanent plus fort jusqu’au.à.la myope. </p> | ||
+ | |||
+ | </section> | ||
+ | |||
+ | <section class="page fourth"> | ||
+ | |||
+ | |||
+ | <artcle> mélancolique merveilleux pluie </artcle> elle rêver de rocambolesque rêver raclette melodie pluie une mais il il pluie myrtille pluie <article> une seule plusieurs ravioli </article> une seule pluie je pluie <article> super merveilleux mais myrtille pluie ah bon pluie </article> bleues la mais fenêtre tu fleurit melodie merveilleux raclette plusieurs je pluie raclette pluie myrtille pluie une seule vert c est rêver fenêtre | ||
+ | |||
+ | </section> | ||
+ | |||
+ | </body> | ||
+ | </html> | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | ---------------------- | ||
+ | <syntaxhighlight lang=css> | ||
+ | |||
@font-face { | @font-face { | ||
font-family: cochin; | font-family: cochin; | ||
Ligne 163 : | Ligne 362 : | ||
} | } | ||
− | + | </syntaxhighlight> | |
Version actuelle datée du 25 avril 2022 à 10:00
bot twitter bis
- la librairie qui permet de se connecter au site
import mechanize
- la librairie qui permet d'analyser la structure html
import lxml.html
- la librairie qui permet de sélectionner une info dans la structure html
import cssselect import random import tweepy
import ssl
liste = [{"id":"Abzakh","name":"abzakh","sort_value":"abzakh"},{"id":"Achhame","name":"achhame(dialecte du n\\u00e9pali)","sort_value":"achhame(dialecte du nepali)"},{"id":"Aheu","name":"aheu","sort_value":"aheu"},{"id":"Aji\\u00eb","name":"aji\\u00eb","sort_value":"ajie"},{"id":"Angait\\u00e9","name":"angait\\u00e9","sort_value":"angaite"},{"id":"Ao","name":"ao","sort_value":"ao"},{"id":"Yemeni Arabic","name":"arabe y\\u00e9m\\u00e9nite ","sort_value":"arabe yemenite "},{"id":"Yemeni Arabic (Sanaa dialect)","name":"arabe y\\u00e9m\\u00e9nite (dialecte de Sanaa)","sort_value":"arabe yemenite (dialecte de Sanaa)"},{"id":"Yemeni Arabic (Zabid dialect)","name":"arabe y\\u00e9m\\u00e9nite (dialecte de Zabid)","sort_value":"arabe yemenite (dialecte de Zabid)"},{"id":"Araki","name":"araki","sort_value":"araki"},{"id":"Arem","name":"arem","sort_value":"arem"},{"id":"Badaga","name":"badaga","sort_value":"badaga"},{"id":"Bafia","name":"bafia","sort_value":"bafia"},{"id":"Bahing","name":"bahing","sort_value":"bahing"},{"id":"Baima","name":"baima","sort_value":"baima"},{"id":"Ban Houei Long dialect of Phay","name":"ban Houei Long (dialecte du phay)","sort_value":"ban Houei Long (dialecte du phay)"},{"id":"Ban Samet dialect of Phay","name":"ban Samet (dialecte du phay)","sort_value":"ban Samet (dialecte du phay)"},{"id":"Burmese","name":"birman","sort_value":"birman"},{"id":"Bislama","name":"bislama","sort_value":"bislama"},{"id":"Bjedug","name":"bjedough","sort_value":"bjedough"},{"id":"Bru","name":"bru","sort_value":"bru"},{"id":"Bulgaro-Mac\\u00e9donien","name":"bulgaro-mac\\u00e9donien","sort_value":"bulgaro-macedonien"},{"id":"Bwatoo","name":"bwatoo","sort_value":"bwatoo"},{"id":"Car-Nicobarais","name":"car-nicobarais","sort_value":"car-nicobarais"},{"id":"C\\u00e8muh\\u00ee","name":"c\\u00e8muh\\u00ee","sort_value":"cemuhi"},{"id":"Chang Naga","name":"chang naga","sort_value":"chang naga"},{"id":"Shapsug","name":"chapsough","sort_value":"chapsough"},{"id":"Chong Heup","name":"chong heup","sort_value":"chong heup"},{"id":"Chong Lo","name":"chong lo","sort_value":"chong lo"},{"id":"Chong Tratt","name":"chong tratt","sort_value":"chong tratt"},{"id":"Chrau","name":"chrau","sort_value":"chrau"},{"id":"Chru","name":"chru","sort_value":"chru"},{"id":"Croate du Burgenland","name":"croate du Burgenland","sort_value":"croate du Burgenland"},{"id":"Cu\\u1ed1i Ch\\u0103m","name":"cu\\u1ed1i ch\\u0103m","sort_value":"cuoi cham"},{"id":"Danu","name":"danu","sort_value":"danu"},{"id":"Dorig","name":"dorig","sort_value":"dorig"},{"id":"Dotyal","name":"dotyal (dialecte du n\\u00e9pali)","sort_value":"dotyal (dialecte du nepali)"},{"id":"Drehu","name":"drehu","sort_value":"drehu"},{"id":"Duoxu","name":"duoxu","sort_value":"duoxu"},{"id":"Ersu","name":"ersu","sort_value":"ersu"},{"id":"Fagauvea","name":"fagauvea","sort_value":"fagauvea"},{"id":"Futunien","name":"futunien","sort_value":"futunien"},{"id":"Ngazidja","name":"grand-comorien","sort_value":"grand-comorien"},{"id":"Ham\\u00e9a","name":"ham\\u00e9a","sort_value":"hamea"},{"id":"Hayu","name":"hayu","sort_value":"hayu"},{"id":"Hiw","name":"hiw","sort_value":"hiw"},{"id":"Iaai","name":"iaai","sort_value":"iaai"},{"id":"Inuktitut","name":"inuktitut","sort_value":"inuktitut"},{"id":"Iraqw","name":"iraqw","sort_value":"iraqw"},{"id":"Ishir","name":"ishir","sort_value":"ishir"},{"id":"Ixcatec","name":"ixcat\\u00e8que","sort_value":"ixcateque"},{"id":"Japhug","name":"japhug","sort_value":"japhug"},{"id":"Jinghpaw","name":"jinghpaw","sort_value":"jinghpaw"},{"id":"Kakabe","name":"kakabe","sort_value":"kakabe"},{"id":"Kam","name":"kam","sort_value":"kam"},{"id":"Karen","name":"karen","sort_value":"karen"},{"id":"Kha Phong","name":"kha phong","sort_value":"kha phong"},{"id":"Khaling","name":"khaling","sort_value":"khaling"},{"id":"Kh\\u00e1ng","name":"kh\\u00e1ng","sort_value":"khang"},{"id":"Cardamom Khmer","name":"khmer des Cardamomes","sort_value":"khmer des Cardamomes"},{"id":"Krom Khmer","name":"khmer krom","sort_value":"khmer krom"},{"id":"Khmu","name":"khmu","sort_value":"khmu"},{"id":"Khroskyabs","name":"khroskyabs","sort_value":"khroskyabs"},{"id":"Kh\\u00fcn","name":"kh\\u00fcn","sort_value":"khun"},{"id":"Koro","name":"koro","sort_value":"koro"},{"id":"Koyi Rai","name":"koyi rai","sort_value":"koyi rai"},{"id":"Ksing Mun","name":"ksing mun","sort_value":"ksing mun"},{"id":"Kurde central","name":"kurde","sort_value":"kurde"},{"id":"Kuy","name":"kuy","sort_value":"kuy"},{"id":"Kw\\u00eanyii","name":"kw\\u00e9ny\\u00ef\\u00ef","sort_value":"kwenyii"},{"id":"Lahu","name":"lahu","sort_value":"lahu"},{"id":"Lakon","name":"lakon","sort_value":"lakon"},{"id":"Langi","name":"langi","sort_value":"langi"},{"id":"Laven","name":"laven","sort_value":"laven"},{"id":"Laze","name":"laze","sort_value":"laze"},{"id":"Laz\\u00e9","name":"laz\\u00e9","sort_value":"laze"},{"id":"Lehali","name":"lehali","sort_value":"lehali"},{"id":"Lemerig","name":"lemerig ","sort_value":"lemerig "},{"id":"Limbu","name":"limbu","sort_value":"limbu"},{"id":"Lizu","name":"lizu","sort_value":"lizu"},{"id":"Lo-Toga","name":"lo-toga","sort_value":"lo-toga"},{"id":"Lovono","name":"lovono","sort_value":"lovono"},{"id":"L\\u00f6y\\u00f6p","name":"l\\u00f6y\\u00f6p","sort_value":"loyop"},{"id":"Lyha","name":"lyha","sort_value":"lyha"},{"id":"Lyngam (dialecte Langkma)","name":"lyngam (dialecte Langkma)","sort_value":"lyngam (dialecte Langkma)"},{"id":"Lyngam (dialecte Nongtrei)","name":"lyngam (dialecte Nongtrei)","sort_value":"lyngam (dialecte Nongtrei)"},{"id":"Maore","name":"mahorais","sort_value":"mahorais"},{"id":"Makong dialect of Bru","name":"makong (dialecte du bru\\/s\\u00f4)","sort_value":"makong (dialecte du bru\\/so)"},{"id":"Malang","name":"malang","sort_value":"malang"},{"id":"Maleng Br\\u00f4","name":"maleng br\\u00f4","sort_value":"maleng bro"},{"id":"Malieng","name":"malieng","sort_value":"malieng"},{"id":"Beijing Mandarin","name":"mandarin","sort_value":"mandarin"},{"id":"M\\u1ea3ng","name":"m\\u1ea3ng","sort_value":"mang"},{"id":"Mankon","name":"mankon","sort_value":"mankon"},{"id":"Maru","name":"maru","sort_value":"maru"},{"id":"Mbugwe","name":"mbugwe","sort_value":"mbugwe"},{"id":"Mizo","name":"mizo","sort_value":"mizo"},{"id":"Mon","name":"m\\u00f4n","sort_value":"mon"},{"id":"Mota","name":"mota","sort_value":"mota"},{"id":"M\\u01b0\\u1eddng","name":"m\\u01b0\\u1eddng","sort_value":"muong"},{"id":"Muya","name":"muya","sort_value":"muya"},{"id":"Mwerlap","name":"mwerlap","sort_value":"mwerlap"},{"id":"Mwesen","name":"mwesen","sort_value":"mwesen"},{"id":"Mwotlap","name":"mwotlap","sort_value":"mwotlap"},{"id":"Na-na\\u0161u (Acquaviva Collecroce)","name":"na-na\\u0161u (Acquaviva Collecroce)","sort_value":"na-nasu (Acquaviva Collecroce)"},{"id":"Na-na\\u0161u (San Felice del Molise)","name":"na-na\\u0161u (San Felice)","sort_value":"na-nasu (San Felice)"},{"id":"Na-na\\u0161u (Montemitro)","name":"na-na\\u0161u\\/na-na\\u0161o (Montemitro)","sort_value":"na-nasu\\/na-naso (Montemitro)"},{"id":"Namakura","name":"namakura","sort_value":"namakura"},{"id":"Nashta","name":"nashta","sort_value":"nashta"},{"id":"Naxi","name":"naxi","sort_value":"naxi"},{"id":"N\\u00eal\\u00eamwa","name":"n\\u00eal\\u00eamwa","sort_value":"nelemwa"},{"id":"Nemi","name":"nemi","sort_value":"nemi"},{"id":"Nengone","name":"nengone","sort_value":"nengone"},{"id":"Nepali","name":"n\\u00e9pali","sort_value":"nepali"},{"id":"Newar","name":"newar","sort_value":"newar"},{"id":"Nivacl\\u00e9","name":"nivacl\\u00e9","sort_value":"nivacle"},{"id":"Nume","name":"nume","sort_value":"nume"},{"id":"Num\\u00e8\\u00e8","name":"num\\u00e8\\u00e8","sort_value":"numee"},{"id":"Nyaheun","name":"nyaheun","sort_value":"nyaheun"},{"id":"Nyesam","name":"nyesam","sort_value":"nyesam"},{"id":"Nyilamba","name":"nyilamba","sort_value":"nyilamba"},{"id":"Olrat","name":"olrat","sort_value":"olrat"},{"id":"Ong","name":"ong","sort_value":"ong"},{"id":"Ubykh","name":"oubykh","sort_value":"oubykh"},{"id":"Ouldeme","name":"ould\\u00e9m\\u00e9","sort_value":"ouldeme"},{"id":"Paic\\u00ee","name":"paic\\u00ee","sort_value":"paici"},{"id":"Pakatan","name":"pakatan","sort_value":"pakatan"},{"id":"Palaong","name":"palaong","sort_value":"palaong"},{"id":"Parlanjhe","name":"parlanjhe","sort_value":"parlanjhe"},{"id":"Pear","name":"pear","sort_value":"pear"},{"id":"Phay","name":"phay","sort_value":"phay"},{"id":"Phong","name":"phong","sort_value":"phong"},{"id":"Phunoi","name":"phunoi","sort_value":"phunoi"},{"id":"Pije","name":"pije","sort_value":"pije"},{"id":"Pnar","name":"pnar","sort_value":"pnar"},{"id":"Pumi","name":"pumi","sort_value":"pumi"},{"id":"Purepecha","name":"purepecha","sort_value":"purepecha"},{"id":"Northern Qiang (Mawo dialect)","name":"qiang du nord (dialecte de Mawo)","sort_value":"qiang du nord (dialecte de Mawo)"},{"id":"Northern Qiang (Qugu dialect)","name":"qiang du nord (dialecte de qugu)","sort_value":"qiang du nord (dialecte de qugu)"},{"id":"Southern Qiang (Sanlong dialect)","name":"qiang du nord (dialecte de sanlong)","sort_value":"qiang du nord (dialecte de sanlong)"},{"id":"Northern Qiang (Shabangou dialect)","name":"qiang du nord (dialecte de shabangou)","sort_value":"qiang du nord (dialecte de shabangou)"},{"id":"Northern Qiang (Shuangliusuo dialect)","name":"qiang du nord (dialecte de shuangliusuo)","sort_value":"qiang du nord (dialecte de shuangliusuo)"},{"id":"Northern Qiang (Waboliangzi dialect)","name":"qiang du nord (dialecte de waboliangzi)","sort_value":"qiang du nord (dialecte de waboliangzi)"},{"id":"Northern Qiang (Zhawo dialect)","name":"qiang du nord (dialecte de zhawo)","sort_value":"qiang du nord (dialecte de zhawo)"},{"id":"Southern Qiang (Goukou dialect)","name":"qiang du nord (dialecte du Goukou)","sort_value":"qiang du nord (dialecte du Goukou)"},{"id":"Northern Qiang (Luoduo dialect)","name":"qiang du nord (dialecte du Luoduo)","sort_value":"qiang du nord (dialecte du Luoduo)"},{"id":"Northern Qiang (Shidiaolou dialect)","name":"qiang du nord (dialecte du Shidiaolou)","sort_value":"qiang du nord (dialecte du Shidiaolou)"},{"id":"Northern Qiang (Weicheng dialect)","name":"qiang du nord (dialecte du Weicheng)","sort_value":"qiang du nord (dialecte du Weicheng)"},{"id":"Southern Qiang (Baishui dialect)","name":"qiang du sud (dialecte du Baishui)","sort_value":"qiang du sud (dialecte du Baishui)"},{"id":"Southern Qiang (Baixi dialect)","name":"qiang du sud (dialecte du Baixi)","sort_value":"qiang du sud (dialecte du Baixi)"},{"id":"Southern Qiang (Heihu Dialect)","name":"qiang du sud (dialecte du Heihu)","sort_value":"qiang du sud (dialecte du Heihu)"},{"id":"Southern Qiang (Longxi dialect)","name":"qiang du sud (dialecte du Longxi)","sort_value":"qiang du sud (dialecte du Longxi)"},{"id":"Southern Qiang (Luobozhai Dialect)","name":"qiang du sud (dialecte du Luobozhai)","sort_value":"qiang du sud (dialecte du Luobozhai)"},{"id":"Queyu","name":"queyu","sort_value":"queyu"},{"id":"Southern Raglai","name":"raglai m\\u00e9ridional","sort_value":"raglai meridional"},{"id":"Northern Raglai","name":"raglai septentrional","sort_value":"raglai septentrional"},{"id":"Rakhine","name":"rakhine","sort_value":"rakhine"},{"id":"Rgyalrong","name":"rgyalrong","sort_value":"rgyalrong"},{"id":"Rmet","name":"rmet","sort_value":"rmet"},{"id":"Romani (Northern Vlax, Mexico)","name":"romani (vlax du nord, Mexique)","sort_value":"romani (vlax du nord, Mexique)"},{"id":"Romani (Xoraxane, Southern Vlax, Greece)","name":"romani (xoraxane, vlax du sud, Gr\\u00e8ce)","sort_value":"romani (xoraxane, vlax du sud, Grece)"},{"id":"R\\u1ee5c","name":"r\\u1ee5c","sort_value":"ruc"},{"id":"S\\u00e1ch","name":"s\\u00e1ch","sort_value":"sach"},{"id":"Saek","name":"saek","sort_value":"saek"},{"id":"Salang","name":"salang","sort_value":"salang"},{"id":"Salar","name":"salar","sort_value":"salar"},{"id":"Samre","name":"samre","sort_value":"samre"},{"id":"Senhaja de Srair (Zerqet)","name":"senhaja de Srair (Zerqet)","sort_value":"senhaja de Srair (Zerqet)"},{"id":"Situ","name":"situ","sort_value":"situ"},{"id":"Siwi","name":"siwi","sort_value":"siwi"},{"id":"Sorabe sup\\u00e9rieur (courant)","name":"sorabe sup\\u00e9rieur (courant)","sort_value":"sorabe superieur (courant)"},{"id":"Stau","name":"stau","sort_value":"stau"},{"id":"Tai Deng","name":"tai deng","sort_value":"tai deng"},{"id":"Tai Don","name":"tai don","sort_value":"tai don"},{"id":"Tai Paw","name":"tai paw","sort_value":"tai paw"},{"id":"Tai Yo","name":"tai yo","sort_value":"tai yo"},{"id":"Tamang","name":"tamang","sort_value":"tamang"},{"id":"Tampuan","name":"tampuan","sort_value":"tampuan"},{"id":"Tanema","name":"tanema","sort_value":"tanema"},{"id":"Tanimuca","name":"tanimuca","sort_value":"tanimuca"},{"id":"Tavoyan","name":"tavoyan","sort_value":"tavoyan"},{"id":"Tay Khang","name":"tay khang","sort_value":"tay khang"},{"id":"T\\u00e0y Po\\u1ecdng","name":"t\\u00e0y po\\u1ecdng","sort_value":"tay poong"},{"id":"Chechen","name":"tch\\u00e9ch\\u00e8ne","sort_value":"tchechene"},{"id":"Teanu","name":"teanu","sort_value":"teanu"},{"id":"Thaungtha","name":"thaungtha","sort_value":"thaungtha"},{"id":"Thavung","name":"thavung","sort_value":"thavung"},{"id":"Th\\u1ed5","name":"th\\u1ed5","sort_value":"tho"},{"id":"Thulung Rai","name":"thulung rai","sort_value":"thulung rai"},{"id":"Tibetan","name":"tib\\u00e9tain","sort_value":"tibetain"},{"id":"Tib\\u00e9tain de l\'Amdo","name":"tib\\u00e9tain de l\'Amdo","sort_value":"tibetain de l\'Amdo"},{"id":"Kami Tibetan","name":"tib\\u00e9tain kami","sort_value":"tibetain kami"},{"id":"Tikar","name":"tikar","sort_value":"tikar"},{"id":"Tikopia","name":"tikopia","sort_value":"tikopia"},{"id":"Tok Pisin","name":"tok pisin","sort_value":"tok pisin"},{"id":"Tomaraho","name":"tomaraho","sort_value":"tomaraho"},{"id":"Toum","name":"toum","sort_value":"toum"},{"id":"Turc de Chypre","name":"turc de Chypre","sort_value":"turc de Chypre"},{"id":"Vatlongos","name":"vatlongos","sort_value":"vatlongos"},{"id":"Vera\'a","name":"vera\'a","sort_value":"vera\'a"},{"id":"Hanoi dialect","name":"vietnamien (dialecte de Hano\\u00ef)","sort_value":"vietnamien (dialecte de Hanoi)"},{"id":"Phong Nha dialect","name":"vietnamien (dialecte de Phong Nha)","sort_value":"vietnamien (dialecte de Phong Nha)"},{"id":"Cao Lao H\\u1ea1 dialect","name":"vietnamien (dialecte du Cao Lao H\\u1ea1 )","sort_value":"vietnamien (dialecte du Cao Lao Ha )"},{"id":"Volow","name":"volow","sort_value":"volow"},{"id":"Vur\\u00ebs","name":"vur\\u00ebs","sort_value":"vures"},{"id":"Vute","name":"vute","sort_value":"vute"},{"id":"Wallisien","name":"wallisien","sort_value":"wallisien"},{"id":"War (dialecte Amwi)","name":"war (dialecte Amwi)","sort_value":"war (dialecte Amwi)"},{"id":"War (dialecte Nongtalang)","name":"war (dialecte Nongtalang)","sort_value":"war (dialecte Nongtalang)"},{"id":"War (dialecte Syndai)","name":"war (dialecte Syndai)","sort_value":"war (dialecte Syndai)"},{"id":"Wayana","name":"wayana","sort_value":"wayana"},{"id":"X\\u00e2r\\u00e2c\\u00f9\\u00f9","name":"x\\u00e2r\\u00e2c\\u00f9\\u00f9","sort_value":"xaracuu"},{"id":"X\\u00e2r\\u00e2gur\\u00e8","name":"x\\u00e2r\\u00e2gur\\u00e8","sort_value":"xaragure"},{"id":"Xumi","name":"xumi","sort_value":"xumi"},{"id":"Yongning Na","name":"yongning na","sort_value":"yongning na"},{"id":"Yucuna","name":"yucuna","sort_value":"yucuna"},{"id":"Yuanga","name":"zuanga ou yuanga","sort_value":"zuanga ou yuanga"}]
def getHtmlElements(url, selecteurCss):
#1. télécharger la source html de la page url browser = mechanize.Browser() browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] browser.set_handle_robots(False) #problème https browser.set_ca_data(context=ssl._create_unverified_context(cert_reqs=ssl.CERT_NONE)) data = browser.open(url, timeout=10) with open("output.txt", 'w') as f: f.write(str(data.read())) #2. analyser la source et la transformer en structure html navigable source = data.read() #print(source) html = lxml.html.fromstring(source.decode('utf-8')) #3. viser l'information qui nous intéresse #convertir mon sélecteur css en objet cssselect selecteurs = cssselect.parse(selecteurCss) #0 #[objet cssselect] selecteur = selecteurs[0] chemin_xpath = cssselect.HTMLTranslator().selector_to_xpath(selecteur) resultats = html.xpath(chemin_xpath) return resultats #print(resultats)
- 1. aller chercher les liens de la liste des corpus par ordre alphabetique
- links = getHtmlElements('https://pangloss.cnrs.fr', '#list a')
print(liste[0])
url = 'https://pangloss.cnrs.fr/corpus/'+liste[0]['id']+'?lang=fr&mode=normal'
print(url)
titre = getHtmlElements(url, 'h1')
print(titre[0].text_content())
article = getHtmlElements(url, 'article p')
print(article[0].text_content())
- for link in links:
- print(link.get('href'))
- goodLinks = []
- for link in links:
- goodLinks.append(link.get('<a href="https://pangloss.cnrs.fr/corpus>'))
- 2. aller chercher le nom de la langue
comments = getHtmlElements(link, '
')
message = link
print ?
- 3. aller chercher un mot au hasard dans le texte de présentaion
comment = random.choice(comments)
print ?
- 4. recommencer chaque jour cette action avec le lien suivant
- for comment in comments:
- print(str(comment.text_content()))
comment = random.choice(comments) message = message + str(comment.text_content()) print(message)
bot twitter
Lundi à 18h bot démarre. Il annonce, il publie « C’est la semaine de (…) ». (…) = une des langues présentent dans la liste des corpus de pangloss, dans l’ordre alphabétique
Mardi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Mercredi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Jeudi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Vendredi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Samedi à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Dimanche à 18h. Il ouvre la page pangloss et va sur la liste des corpus et sélectionne la première langue (ici abzakh). Dans le paragraphe d’introduction il sélectionne au hasard un mot. Il publie ce mot.
Exercice
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="untitled.css">
</head>
<body>
<img id="bara1" src="bara1.JPG" alt="bara1">
<img id="bara2" src="bara2.JPG" alt="bara2">
<img id="bara3" src="bara3.JPG" alt="bara3">
<img id="bara4" src="bara4.JPG" alt="bara4">
<img id="barbe1" src="barbe1.JPG" alt="barbe1">
<img id="barbe2" src="barbe2.JPG" alt="barbe2">
<img id="barbe3" src="barbe3.JPG" alt="barbe3">
<img id="derby1" src="derby1.JPG" alt="derby1">
<img id="derby2" src="derby2.JPG" alt="derby2">
<img id="derby3" src="derby3.JPG" alt="derby3">
<section class="page first">
<article> La myopie
_________
Permettre un </article> voile flou sans <article> réticences, sans contraindre </article> <article> ses yeux à y voir net. </artcile> Une vision <article> nuageuse omni-constante</article> , <article> pour une existence </article> moins consciente. Moins <article> consciente </article> des lieux, moins consciente des visages, moins consciente des f </article>
</section>
<section class="page second">
<p> ormes, moins consciente des lignes, moins consciente des objets, moins consciente des matériaux. Un adoucissement des contours. Un paysage où les choses se fondent entre elles sans se toucher. Lieux se confondent et espaces semblent être une seule et même chose. Les regards des au </p>
</section>
<section class="page third">
<p> tres humain.e.s plus abstrait. Une chorégraphie des corps moins saccadée qui s’étale dans le temps sans discontinuer. La vue des choses est sans réponse claire. Les secrets sont gardés. Les corps rayonnants émanent plus fort jusqu’au.à.la myope. </p>
</section>
<section class="page fourth">
<artcle> mélancolique merveilleux pluie </artcle> elle rêver de rocambolesque rêver raclette melodie pluie une mais il il pluie myrtille pluie <article> une seule plusieurs ravioli </article> une seule pluie je pluie <article> super merveilleux mais myrtille pluie ah bon pluie </article> bleues la mais fenêtre tu fleurit melodie merveilleux raclette plusieurs je pluie raclette pluie myrtille pluie une seule vert c est rêver fenêtre
</section>
</body>
</html>
@font-face {
font-family: cochin;
src: url('cochin.ttc');
}
*{
box-sizing:border-box;
}
html, body
{
font-family:cochin;
font-size:13pt;
color: red;
background: hsl(240, 70%, 90%);
display: inline;
}
section.page{
width:15mm;
height: 200mm;
border:1px solid black;
line-height: -600px;
margin:10px;
padding:5mm;
}
section.page.first
{
background: hsla(0, 100%, 50%, 0.5);
position: relative;
top: -3000px;
bottom: 10px;
left: 10px;
right: 10px ;
}
section.page.second
{
background: hsla(100, 100%, 50%, 0.5);
position: relative;
top: -2300px;
bottom: 50px;
left: 50px;
right: 50px ;
}
section.page.third
{
background: hsla(300, 100%, 50%, 0.5);
position: relative;
top: -2300px;
bottom: 100px;
left: 100px;
right: 100px ;
}
section.page.fourth
{
background: hsla(340, 10%, 50%, 0.4);
position: relative;
top: -2300px;
bottom: 100px;
left: 100px;
right: 100px ;
}
article{
width:100%;
display:flex;
}
div{
width:50%;
padding:3mm;
}
p{
margin:1rem 0 0 0;
line-height:1rem;
font-size:0.9rem;
}
p.highlight{
font-size:1.9rem;
line-height:2rem;
}
h2{
font-weight:normal;
margin:0 0 1rem 0;
/*margin-bottom:2rem;*/
line-height:2rem;
font-size:1.8rem;
text-align:center;
}
#bara1, #bara2,#bara3,#bara4
{
max-width: 40%;
max-height: 40%;
margin-top: 3%;
margin-right: 3%;
margin-left: 3%;
}
#derby1, #derby2,#derby3
{
max-width: 40%;
max-height: 40%;
margin-top: 3%;
margin-right: 3%;
margin-left: 3%;
}
#barbe1,#barbe2, #barbe3
{
max-width: 60%;
max-height: 60%;
margin-top: 3%;
margin-right: 3%;
margin-left: 3%;
}
.article
{
width:1mm;
height: 2mm;
border:100px solid black;
line-height: -600px;
margin:100px;
padding:500mm;
}
@media print
{
@page
{
size: 220mm 300mm;
}
body
{
display: block;
margin: 0;
}
section.page
{
margin: 0;
border:1px solid black;
margin:10px;
padding:5mm;
position: relative;
top: -2250;
}
}
- remplacer toutes les lettres d'une phrase, ici pangramme, par un mot
{
sample_string = "z o e m a g r a n d e f i l l e v e u t q u e j e b o i v e c e w h i s k y d o n t j e n e v e u x p a s "
char_to_replace = {
'a': 'rêver', 'b': 'super', 'c': 'ah bon', 'd': 'melodie',
etcetctetectctctetetc
sample_string = sample_string.translate(str.maketrans(char_to_replace))
print(sample_string)
}
# -*- coding: utf8 -*-
voix_un = int(input("Enter first number "))
voix_deux = int(input("Enter second number "))
print("\n")
print("First Number:", voix_un)
print("Second Number:", voix_deux)
x = voix_un + voix_deux
if x == 2:
print("100 %")
elif x == 12 :
print ("100%")
elif x == 3 :
print ("90%")
elif x == 13 :
print ("90%")
elif x == 4 :
print ("80%")
elif x == 14 :
print ("80%")
elif x == 5 :
print ("70%")
elif x == 15 :
print ("70%")
elif x == 6 :
print ("60%")
elif x == 16 :
print ("60%")
elif x == 7 :
print ("50%")
elif x == 17 :
print ("50%")
elif x == 8 :
print ("40%")
elif x == 18 :
print ("40%")
elif x == 9 :
print ("30%")
elif x == 19 :
print ("30%")
elif x == 10 :
print ("20%")
elif x == 20 :
print ("20%")
elif x == 11 :
print ("10%")
else :
print ("bizarre")
scale map processing java function