Created
October 17, 2017 13:39
-
-
Save jQwotos/37c54992881824d7084680ee91c9633c to your computer and use it in GitHub Desktop.
A basic scraper that scrapes search results from flipp.com
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 requests | |
BASE_URL = 'https://flipp.com' | |
BACKEND_URL = 'https://backflipp.wishabi.com/flipp' | |
SEARCH_URL = '%s/items/search' % BACKEND_URL | |
ITEM_URL = '%s/items/' % BACKEND_URL | |
def scrape_item(item_id): | |
return requests.get( | |
"%s/%s" % (ITEM_URL, item_id,) | |
).json() | |
def search(query, postal_code): | |
data = requests.get( | |
SEARCH_URL, | |
params = { | |
'q': query, | |
'postal_code': postal_code, | |
} | |
).json() | |
return [ | |
scrape_item(x.get('flyer_item_id')) | |
for x in data.get('items') | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment