File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1- from urllib .request
2- import urlopenfrom bs4
3- import BeautifulSoupimport re
1+ from urllib .request import urlopen
2+ from bs4 import BeautifulSoup
3+ import re
44
55html = urlopen ("http://www.pythonscraping.com/pages/page3.html" )
66bsObj = BeautifulSoup (html )
77images = bsObj .findAll ("img" , {"src" :re .compile ("\.\.\/img\/gifts/img.*\.jpg" )})
88for image in images :
9- print (image ["src" ])
9+ print (image ["src" ])
Original file line number Diff line number Diff line change 88table = bsObj .findAll ("table" ,{"class" :"wikitable" })[0 ]
99rows = table .findAll ("tr" )
1010
11- csvFile = open ("../ files/editors.csv" , 'wt' )
11+ csvFile = open ("files/editors.csv" , 'wt' )
1212writer = csv .writer (csvFile )
1313try :
14- for row in rows :
15- csvRow = []
16- for cell in row .findAll (['td' , 'th' ]):
17- csvRow .append (cell .get_text ())
18- writer .writerow (csvRow )
14+ for row in rows :
15+ csvRow = []
16+ for cell in row .findAll (['td' , 'th' ]):
17+ csvRow .append (cell .get_text ())
18+ writer .writerow (csvRow )
1919finally :
20- csvFile .close ()
20+ csvFile .close ()
You can’t perform that action at this time.
0 commit comments