from pprint import pprint
import os
import googlemaps # pip install googlemaps
import win32com.client as win32
API_KEY = open('API.txt').read()
map_client = googlemaps.Client(API_KEY)
def get_place_info(location_name):
try:
# location_name = 'Lanxess Arena Köln'
response = map_client.places(query=location_name)
results = response.get('results')[0]
return results
except Exception as e:
print(e)
return None
xlApp = win32.Dispatch('Excel.Application')
xlApp.Visible = True
wb = xlApp.workbooks.open(os.path.join(os.getcwd(), 'output.xlsx'))
wsList = wb.Worksheets('List')
LastRow = wsList.Cells(wsList.Rows.Count, 'A').End(-4162).Row
for i in range(2, LastRow+1):
place_info = get_place_info(wsList.Cells(i, 1).Value)
wsList.cells(i, 2).Value = place_info['name']
wsList.cells(i, 3).Value = place_info['formatted_address']
wsList.cells(i, 4).Value = place_info['place_id']
wsList.cells(i, 5).Value = place_info['rating']
wsList.cells(i, 6).Value = place_info['user_ratings_total']
wb = None
wsList = None
xlApp = None Python programı revize edilecek
0
●74
- 10-11-2022, 19:59:04Kimlik doğrulama veya yönetimden onay bekliyor.Merhaba, elimde basit bir Python betiği var. Excell'de ilk sütüna işletme adığını yazdığım zaman adresini bulabiliyorum. Ama ben bunun yanında telefon numarası ve web adresini de bulup yazdırmasını istiyorum. Betiğin çalışır halini olduğu gibi paylaşıyorum. İlgilenen arkadaşlar fiyat bilgisi ile geri dönüş yapabilirler. İŞ ACİL.