Skip to content

Instantly share code, notes, and snippets.

@vwillcox
Created July 31, 2018 18:48
Show Gist options
  • Save vwillcox/e98a1351eadafe11cef08148ea2997ec to your computer and use it in GitHub Desktop.
Save vwillcox/e98a1351eadafe11cef08148ea2997ec to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
response = requests.get('http://www.tesco.com/groceries/en-GB/search?query=blueberry')
soup = BeautifulSoup(response.text, 'html.parser')
for item in soup.select('.product-list--list-item'):
try:
product = item.find(class_='product-image').get('alt', '')
value = item.find(class_='value').get_text()
print (product, '£'+value)
except AttributeError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment