jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/510276 )
Change subject: [IMPR] Fix deprecation warnings in imageharvest.py
......................................................................
[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(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
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
https://gerrit.wikimedia.org/r/510276
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib460f26b32dfeabb645d0eef5470569f77ee9724
Gerrit-Change-Number: 510276
Gerrit-PatchSet: 3
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)