forked from mertkaya0/market
-
Notifications
You must be signed in to change notification settings - Fork 0
/
market.py
54 lines (36 loc) · 1.45 KB
/
market.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import googlemaps
import pandas as pd
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def your_loc():
options = Options()
options.headless = False
options.add_argument("--window-size=0,0")
driver = webdriver.Chrome(options=options)
url = "https://findmylocation.org/"
driver.set_window_position(2000,2000)
driver.get(url)
my_lat = float(driver.find_element_by_xpath("//*[@id='latitude']").text)
my_lng = float(driver.find_element_by_xpath("//*[@id='longitude']").text)
driver.close()
return (my_lat,my_lng)
def market(your_location):
market_adi = ["Migros","CarrefourSA","Şok","A-101"]
map_client = googlemaps.Client("**YOUR_API_KEY**")
location = your_location
distance = 350
business_list = []
for i in market_adi:
response = map_client.places_nearby(location=location, name=i, radius=distance)
business_list.extend(response.get("results"))
def konum_isim(liste):
lat = []
lng = []
m_adı = []
for i in liste:
lat.append(((i["geometry"])["location"])["lat"])
lng.append(((i["geometry"])["location"])["lng"])
m_adı.append((i["name"]))
dataframe = pd.DataFrame({"Lat": lat,"Lng":lng, "Market": m_adı})
return dataframe
return konum_isim(business_list)