diff options
author | Lionel <lionel.miquel46@gmail.com> | 2018-10-04 08:13:08 +0200 |
---|---|---|
committer | Lionel <lionel.miquel46@gmail.com> | 2018-10-04 08:13:08 +0200 |
commit | 8fd35574400834517db2a51e92eba970f614843e (patch) | |
tree | efc032a6f130e80b0422159724654fadce6e99ce /randoweb.py | |
parent | 0943dd142523b53e3748987fd16c77e6567c2fab (diff) | |
download | randopitons-8fd35574400834517db2a51e92eba970f614843e.tar.gz randopitons-8fd35574400834517db2a51e92eba970f614843e.zip |
On a encore plus nettoyé tout ce bazard, on va maintenant améliorer le sctrip
t pour le parsing des fichiers
Diffstat (limited to 'randoweb.py')
-rw-r--r-- | randoweb.py | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/randoweb.py b/randoweb.py index c714a40..cb1b7c7 100644 --- a/randoweb.py +++ b/randoweb.py @@ -1,32 +1,21 @@ from requests import session -import getpass - -import os +import inputs from bs4 import BeautifulSoup as bs -def main(region,maptype): - MAIL=raw_input("Your email to log in to randopitons.re : ") - PSW=getpass.getpass(prompt="Your password to log in to randopitons.re: ") - - - payload = { - 'mail': MAIL, - 'password': PSW - } - with session() as c: try: post('https://randopitons.re/connexion', data=payload) + region = c.get('https://randopitons.re/randonnees/region/'+region) + wsite=bs(region) except SSLError, sslerr: print "SSL Certificate Error. Please check the time on your computer, adjust it accordingly, or wait a bit before retrying the downloads." - region = c.get('https://randopitons.re/randonnees/region/'+region) - wsite=bs(region) + - randonb=[] + for i in wsite.find_all('tr'): randonb.append(i.get("rid")) @@ -34,22 +23,11 @@ def main(region,maptype): for i in randonb: dwnld = c.get('https://randopitons.re/randonnee/'+i+'/trace/'+maptype) gudencoding=dwnld.text.encode('utf-8') + gpxf=open('f.gpx','a+') gpxf.write(gudencoding) gpxf.close() - try: - tree=xmlp.parse('f.gpx') - root=tree.getroot() - filename=root[1][0].text+".gpx" - os.rename('f.gpx',filename) - except OSError, e: - print("Operating System error: {0}".format(e)) - except xml.etree.ElementTree.ParseError,e: - print("Something occured with the formating:{0} . File is not retrievable, passing on next download.".format(e)) - os.remove('f.gpx') - pass - - + print("FINISHED WRITING FILES") except OSError, e: print("Operating System error: {0}".format(e)) |