How to grab the list of shops and make a google my map for repas.it?

In some institute part of the salary is delivered as lunch coupons. These coupons could be used in limited number of shops. Our target is to make a google my map based on information from repas.it.

Here I provide a half-automatic way.

  1. Go to repas.it and choose “search”
  2. choose the city and click on “search” button, and wait until the list of shops appeared.
  3. save the page as a html file, or so-called page source.
    • for example. here you can download the page source for L’Aquila:
  4. You can check its content with vi or emacs. The first two numbers are gps co-ordinate. They are quite imprecise.. repas people are quite lazy.
  5. use my script to grab the gps co-ordinate, the address and the name of the shop from this file. You will get a file called output.csv.
    #!/bin/python
    #coding=utf-8
    import HTMLParser
    
    html_parser = HTMLParser.HTMLParser()
    
    rfile='Cerca il locale.htm'
    
    with open(rfile) as f:
        content = f.readlines()
        results=[]
        for line in content:
            result=[]
            if not line.strip().startswith('document.locations.push'):
                continue
            processed=line.strip("\t\t\tdocument.locations.push([").strip("]);\n").split("', ")
            Ngps=(processed[0].strip("'"))
            Egps=(processed[1].strip("'"))
            result.append(Ngps)
            result.append(Egps)
            p2=html_parser.unescape(processed[2].strip("'").strip('"')).split("<br />")
            for p3 in p2:
                p3pos=-1
                while not p3.find("<",p3pos+1)==-1:
                    p3pos=p3.find("<",p3pos+1)
                    p3rpos=p3.find(">",p3pos+1)+1
                    p3=p3[0:p3pos]+p3[p3rpos:]
                    p3pos=-1
                p4=p3.replace(","," ").replace("\\","")
                result.append(p4)
            results.append(result)
    
    wfile='output.csv'
    wf=open(wfile,"w")
    wf.write("GPS1,GPS2,Name,Address\n")
    for result in results:
        wf.write(result[0]+","+result[1]+","+result[2]+","+result[3]+"\n")
    wf.close()
    

– You can try to download
process.py
– and rename it as “process.py”

  1. open google mymap, create a new map, and import the csv file we just create. I think you should know what to do next.

Good luck

.