· 6 years ago · Nov 15, 2019, 02:16 AM
1import urllib.request, urllib.parse, os
2from pathlib import Path
3
4with open(r'C:\temp\real-estate\propertylist.txt', 'r') as f:
5 f_contents = [line.rstrip('\n') for line in f]
6
7myloc = "C:/temp/real-estate" #replace with your own location
8key = "&key=" + "<google api key>" #got banned after ~100 requests with no key
9
10def GetStreet(Add,SaveLoc):
11 base = "https://maps.googleapis.com/maps/api/streetview?size=640x640&location="
12 MyUrl = base + urllib.parse.quote_plus(Add) + key #added url encoding
13 fi = Add + ".jpg"
14 urllib.request.urlretrieve(MyUrl, os.path.join(SaveLoc,fi))
15
16for i in f_contents:
17 GetStreet(Add=i,SaveLoc=myloc)