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
#Restaurant Price for 2 | |
try: | |
price_for_2_anchor = driver.find_element_by_xpath("""/html/body/div[1]/div[2]/main/div/section[4]/section/section/article[1]/section[2]/p[1]""") | |
price_for_2_text = price_for_2_anchor.text | |
except NoSuchElementException: | |
price_for_2_text = "No Price Data Found" | |
pass | |
if (price_for_2_text[0:2] == 'Rp') or (price_for_2_text[0:2] == 'No'): |
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
#Restaurant Additional Information | |
addt_info_list = [] | |
addt_info_bigelt = driver.find_element_by_xpath("""/html/body/div[1]/div[2]/main/div/section[4]/section/section/article[1]/section[2]/div[3]""") | |
addt_info_eltlist = addt_info_bigelt.find_elements_by_tag_name('p') | |
for addt_info_anchor in addt_info_eltlist: | |
addt_info_text = addt_info_anchor.text | |
addt_info_list.append(addt_info_text) | |
rest_info.append(addt_info_list) |
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
#Restaurant Latitude and Longitude | |
map_url = driver.find_element_by_xpath("""/html/body/div[1]/div[2]/main/div/section[4]/section/article/section/div[2]/a""").get_attribute("href") | |
lat = map_url[-28:-15] | |
long = map_url[-14:-1] | |
rest_lat.append(lat) | |
rest_long.append(long) | |
print(f'Scraping Restaurant Latitude-Longitude - {name} - {lat} - {long} - OK') |
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 Libraries | |
import requests | |
import json | |
import datetime | |
import pandas as pd | |
# Define Parameters Dictionary | |
params = dict() | |
params['access_token'] = 'XXXXXXXXXXXXXXXXXXX' # not an actual access token | |
params['client_id'] = '111111111111' # not an actual client id |
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
# Define Endpoint Parameters | |
endpointParams = dict() | |
endpointParams['input_token'] = params['access_token'] | |
endpointParams['access_token'] = params['access_token'] | |
# Define URL | |
url = params['graph_domain'] + '/debug_token' | |
# Requests Data | |
data = requests.get(url, endpointParams) |
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
print("Token Expires: ", datetime.datetime.fromtimestamp(access_token_data['data']['expires_at'])) |
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
# Define URL | |
url = params['endpoint_base'] + 'oauth/access_token' | |
# Define Endpoint Parameters | |
endpointParams = dict() | |
endpointParams['grant_type'] = 'fb_exchange_token' | |
endpointParams['client_id'] = params['client_id'] | |
endpointParams['client_secret'] = params['client_secret'] | |
endpointParams['fb_exchange_token'] = params['access_token'] |
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
# Define URL | |
url = params['endpoint_base'] + params['instagram_account_id'] + '/media' | |
# Define Endpoint Parameters | |
endpointParams = dict() | |
endpointParams['fields'] = 'id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username,like_count,comments_count' | |
endpointParams['access_token'] = params['access_token'] | |
# Requests Data | |
data = requests.get(url, endpointParams ) |
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
df = pd.DataFrame(basic_insight['data']) | |
df.columns = ['id', 'Caption', 'Media_Type', 'Media_URL', 'Permalink', 'Timestamp', 'Username', 'Likes', 'Comments'] | |
df.head() |
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
media_insight = [] | |
# Loop Over 'Media ID' | |
for i in basic_insight['data']: | |
params['latest_media_id'] = i['id'] | |
# Define URL | |
url = params['endpoint_base'] + params['latest_media_id'] + '/insights' | |
# Define Endpoint Parameters |