-
-
Save AnderRV/a1a33d102e43893f278b379dd17e104c 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
import json | |
import defaults | |
import repo | |
def extract_content(url, soup): | |
return [{ | |
'id': product.find('a', | |
attrs={'data-product_id': True})['data-product_id'], | |
'name': product.find('h2').text, | |
'price': product.find(class_='amount').text | |
} for product in soup.select('.product')] | |
def store_content(url, content): | |
for item in content: | |
if item['id']: | |
repo.set_content(item['id'], json.dumps(item)) | |
def allow_url_filter(url): | |
return '/shop/page/' in url and '#' not in url | |
def get_html(url): | |
return defaults.get_html(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment