Created
August 11, 2021 15:12
-
-
Save AnderRV/e6544267ac8417d2cc690e15f9c39961 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
data = [] | |
def extract_content(soup): | |
for product in soup.select('.product'): | |
data.append({ | |
'id': product.find('a', attrs={'data-product_id': True})['data-product_id'], | |
'name': product.find('h2').text, | |
'price': product.find(class_='amount').text | |
}) | |
print(data) | |
# [{'id': '759', 'name': 'Bulbasaur', 'price': '£63.00'}, {'id': '729', 'name': 'Ivysaur', 'price': '£87.00'}, ...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment