Created
November 23, 2020 23:15
-
-
Save apachols/bcecd18b0b0c4f44ecf810904e878e23 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
# COMPARE | |
import requests | |
HOST = 'https://staging-growth.webapp.staging.internal.rover.com' | |
def api_call(uri): | |
url = f'{HOST}{uri}' | |
return requests.get(url).json() | |
def get_cv3_urls(data): | |
return [ | |
row['profile_url'] | |
for row in data['results'] | |
] | |
def get_browse_urls(data): | |
return [ | |
row['web_url'] | |
for row in data['results'] | |
] | |
def compare_urls(list1, list2): | |
if len(set(list1)) != len(set(list2)): | |
return ['set length fails'] | |
if set(list1) != set(list2): | |
compare = set(list1) - set(list2) | |
return [ | |
url.replace(f'{HOST}/members/', '') | |
for url in compare | |
] | |
return [] | |
city_list = [ | |
'seattle--wa--dog-boarding', | |
'portland--or--dog-boarding', | |
'san-diego--ca--dog-boarding', | |
'los-angeles--ca--dog-boarding', | |
'tacoma--wa--dog-boarding', | |
] | |
for city in city_list: | |
cv3_data = api_call(f'/api/v4/frontend/location-service/{city}') | |
cv3_urls = get_cv3_urls(cv3_data) | |
browse_data = api_call(f'/api/v4/search-optimized/?seo_location_slug={city}') | |
browse_urls = get_browse_urls(browse_data) | |
comparison = compare_urls(cv3_urls, browse_urls) | |
if len(comparison) == 0: | |
print(f'{city} exact match') | |
else: | |
print(f'{city} has cv3 not in browse:') | |
print('---------') | |
for dud in comparison: | |
print(f' {dud}') | |
print('---------') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment