Skip to content

Commit dfc485b

Browse files
committed
Sehepunkte import: Port to requests and use https
Ref syslabcom/scrum#2402
1 parent 7a3fff3 commit dfc485b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/recensio/plone/browser/sehepunkte.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import html.entities
2222
import logging
2323
import re
24-
import urllib
24+
import requests
2525

2626

2727
log = logging.getLogger(__name__)
@@ -105,7 +105,8 @@ def __call__(self):
105105
review_count = 0
106106
for url in self._getTargetURLs():
107107
try:
108-
sehepunkte_xml = urllib.request.urlopen(url).read() # nosec B310
108+
response = requests.get(url)
109+
sehepunkte_xml = response.content
109110
data.append(sehepunkte_parser.parse(sehepunkte_xml))
110111
except OSError:
111112
pass # The library takes care of logging a failure
@@ -133,7 +134,7 @@ def __call__(self):
133134
return "Success"
134135

135136
def _getTargetURLs(self):
136-
base = "http://www.sehepunkte.de/export/sehepunkte_%s.xml"
137+
base = "https://www.sehepunkte.de/export/sehepunkte_%s.xml"
137138
now = datetime.datetime.now()
138139
past_months = int(self.request.get("past_months", 1))
139140
for idx in reversed(range(past_months + 1)):
@@ -225,7 +226,8 @@ def setter(mapper):
225226

226227
def _extractAndSanitizeHTML(self, review):
227228
# XXX check scheme? (bandit)
228-
html = urllib.request.urlopen(review["canonical_uri"]).read() # nosec B310
229+
response = requests.get(review["canonical_uri"])
230+
html = response.content
229231
soup = BeautifulSoup(html, "lxml")
230232
dirt = soup.findAll("div", {"class": "box"})
231233
for div in dirt:

0 commit comments

Comments
 (0)