Skip to content

Commit 9199fb6

Browse files
author
Adam Yang
committed
Fix code issues and upgrade libraries to python3
1 parent 805c7ec commit 9199fb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+187
-326
lines changed

chapter1/.DS_Store

-6 KB
Binary file not shown.

chapter1/2-beautifulSoup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from bs4 import BeautifulSoup
33

44
html = urlopen("http://www.pythonscraping.com/exercises/exercise1.html")
5-
bsObj = BeautifulSoup(html.read())
5+
bsObj = BeautifulSoup(html, "html.parser")
66
print(bsObj.h1)

chapter1/3-exceptionHandling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def getTitle(url):
1111
print(e)
1212
return None
1313
try:
14-
bsObj = BeautifulSoup(html.read())
14+
bsObj = BeautifulSoup(html, "html.parser")
1515
title = bsObj.body.h1
1616
except AttributeError as e:
1717
return None

chapter10/2-waitForLoad.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from selenium import webdriver
12
from selenium.webdriver.common.by import By
23
from selenium.webdriver.support.ui import WebDriverWait
34
from selenium.webdriver.support import expected_conditions as EC

chapter11/ghostdriver.log

Lines changed: 0 additions & 36 deletions
This file was deleted.

chapter11/page.jpg

-68.3 KB
Binary file not shown.

chapter11/page.txt

Lines changed: 0 additions & 47 deletions
This file was deleted.

chapter13/1-wikiUnitTest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def test_PageProperties(self):
1818
url = "http://en.wikipedia.org/wiki/Monty_Python"
1919
#Test the first 100 pages we encounter
2020
for i in range(1, 100):
21-
bsObj = BeautifulSoup(urlopen(url))
21+
bsObj = BeautifulSoup(urlopen(url), 'html.parser')
2222
titles = self.titleMatchesURL()
23-
self.assertEquals(titles[0], titles[1])
23+
self.assertEqual(titles[0], titles[1])
2424
self.assertTrue(self.contentExists())
2525
url = self.getNextLink()
2626
print("Done!")

chapter13/2-wikiSeleniumTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
driver = webdriver.PhantomJS(executable_path='/Users/ryan/Documents/pythonscraping/code/headless/phantomjs-1.9.8-macosx/bin/phantomjs')
55
driver.get("http://en.wikipedia.org/wiki/Monty_Python")
66
assert "Monty Python" in driver.title
7-
print("Monty Python was not in the title")
7+
print("Monty Python was in the title")
88
driver.close()

chapter13/4-dragAndDrop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
actions = ActionChains(driver)
1616
actions.drag_and_drop(element, target).perform()
1717

18-
print(driver.find_element_by_id("message").text)
18+
print(driver.find_element_by_id("message").text)
19+
20+
driver.close()

0 commit comments

Comments
 (0)