Skip to content

Instantly share code, notes, and snippets.

@mattvpham
Created July 11, 2013 02:09
Show Gist options
  • Save mattvpham/5971955 to your computer and use it in GitHub Desktop.
Save mattvpham/5971955 to your computer and use it in GitHub Desktop.
Simple python scraper using Mechanize and BeautifulSoup.
from bs4 import BeautifulSoup
import mechanize
if __name__ == '__main__':
response = mechanize.urlopen("http://fd2-www.leclercdrive.fr/031801/courses/pgeWMEL009_Courses.aspx")
soup = BeautifulSoup(response.read())
products = soup.find_all('div', 'divPrdContaineur')
for product in products:
name1 = product.find('div', 'divLibelle1').string
name2 = product.find('div', 'divLibelle2').string
price = product.find('span', 'spanPrixProduit').string
pricePerUnitMeasure = product.find('span', 'spanPrixUniteMesure').string
results = [s.strip() for s in [name1, name2, price, pricePerUnitMeasure]]
for result in results:
print(result + ', '),
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment