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.
- Go to repas.it and choose “search”
- choose the city and click on “search” button, and wait until the list of shops appeared.
- save the page as a html file, or so-called page source.
- for example. here you can download the page source for L’Aquila:
- 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.
- 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.strip("'")) Egps=(processed.strip("'")) result.append(Ngps) result.append(Egps) p2=html_parser.unescape(processed.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+","+result+","+result+","+result+"\n") wf.close()
– You can try to download
– and rename it as “process.py”
- open google mymap, create a new map, and import the csv file we just create. I think you should know what to do next.