Skip to content

Commit 7155304

Browse files
Ryan MitchellRyan Mitchell
authored andcommitted
2 parents 698fdde + 1ef2cb2 commit 7155304

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

chapter2/6-regularExpressions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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

55
html = urlopen("http://www.pythonscraping.com/pages/page3.html")
66
bsObj = BeautifulSoup(html)
77
images = bsObj.findAll("img", {"src":re.compile("\.\.\/img\/gifts/img.*\.jpg")})
88
for image in images:
9-
print(image["src"])
9+
print(image["src"])

chapter5/3-scrapeCsv.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
table = bsObj.findAll("table",{"class":"wikitable"})[0]
99
rows = table.findAll("tr")
1010

11-
csvFile = open("../files/editors.csv", 'wt')
11+
csvFile = open("files/editors.csv", 'wt')
1212
writer = csv.writer(csvFile)
1313
try:
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)
1919
finally:
20-
csvFile.close()
20+
csvFile.close()

0 commit comments

Comments
 (0)