jenkins-bot merged this change.
[IMPR] Fix deprecation warnings in imageharvest.py
- BeautifulSoup requires clearly defined parser to make sure it behaves
correctly on any setup. This patch will clearly define default Python
HTML parser to be used
- urllib.URLOpener is deprecated
Change-Id: Ib460f26b32dfeabb645d0eef5470569f77ee9724
---
M scripts/imageharvest.py
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/scripts/imageharvest.py b/scripts/imageharvest.py
index c437253..d67f43b 100644
--- a/scripts/imageharvest.py
+++ b/scripts/imageharvest.py
@@ -37,9 +37,9 @@
if not PY2:
import urllib
- from urllib.request import URLopener
+ from urllib.request import urlopen
else:
- from urllib import URLopener
+ from urllib import urlopen
fileformats = ('jpg', 'jpeg', 'png', 'gif', 'svg', 'ogg')
@@ -51,9 +51,8 @@
raise BeautifulSoup
links = []
- uo = URLopener()
- with uo.open(url) as f:
- soup = BeautifulSoup(f.read())
+ with urlopen(url) as f:
+ soup = BeautifulSoup(f.read(), 'html.parser')
if not shown:
tagname = 'a'
To view, visit change 510276. To unsubscribe, or for help writing mail filters, visit settings.