Last active
November 11, 2020 16:31
-
-
Save hehehaha0228/c5f2f393e6e7b20e4a315d1fe9416deb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import googlemaps | |
import os | |
google_key = "AIzaSyCLfZQjoR4uuH3-gikZOf01XLltl_bSlxx" | |
gmaps = googlemaps.Client(key = google_key) | |
#前面一樣要先取得google key,還有設定client | |
#下面這邊,我假設妳已經取得了10個photo_reference,並且將他們存在list裡面 | |
n = 0 | |
for storePhoto_reference in storePhoto_references: | |
try: | |
photo = gmaps.places_photo(photo_reference = storePhoto_reference, max_width=800, max_height=800) | |
#這邊參數一個當然是傳如photo_reference,另外也可以設定最大高度和寬度,最大都為1600,依照你的需求設定。 | |
f = open(str(n) + ".png", "wb") | |
#這邊我設定了我的檔案名稱還有存取的方式,因為圖片檔案是二進位檔案,所以用"wb" | |
for chunk in photo: | |
if chunk: | |
f.write(chunk) | |
f.close() | |
n = n+1 | |
except: | |
print(fileName + "failed") | |
continue | |
print(storeName + "結束") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment