aboutsummaryrefslogtreecommitdiff
path: root/randoweb.py
blob: 6bc18bba84491a176ed2c6a34a91f6dd7a449b62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from requests import session
import inputs
from bs4 import BeautifulSoup as bs
import colorcode as clc
import errmsg as e


def randoweb():
    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 e.sslerr
            
        

        
        for i in wsite.find_all('tr'):
            randonb.append(i.get("rid"))

        try:
            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()
                
            print("Finished writing files.")
        except OSError, e:
            print e.os
            print format(e)
        
        

#print(response.headers)
#print(response.text)