Created
July 11, 2013 02:09
-
-
Save mattvpham/5971955 to your computer and use it in GitHub Desktop.
Simple python scraper using Mechanize and BeautifulSoup.
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
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 + ', '), | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment