mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace urllib with self.index_to_soup()
urllib is no longer used to make requests. Instead self.index_to_soup() is called, with raw=True.
This commit is contained in:
parent
526969213c
commit
7567ced528
@ -1,8 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from http.cookiejar import Cookie
|
from http.cookiejar import Cookie
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -267,8 +265,8 @@ class Economist(BasicNewsRecipe):
|
|||||||
self.log('Got cover:', self.cover_url)
|
self.log('Got cover:', self.cover_url)
|
||||||
else:
|
else:
|
||||||
date8 = self.INDEX[-10:].replace('-', '')
|
date8 = self.INDEX[-10:].replace('-', '')
|
||||||
resource = urllib.request.urlopen("https://www.economist.com/weeklyedition/archive?year={}".format(date8[:4]))
|
archive_url = "https://www.economist.com/weeklyedition/archive?year={}".format(date8[:4])
|
||||||
archive = resource.read().decode(resource.headers.get_content_charset())
|
archive = self.index_to_soup(archive_url, raw=True).decode("utf-8")
|
||||||
if date8 in archive:
|
if date8 in archive:
|
||||||
parts = archive.split(date8)
|
parts = archive.split(date8)
|
||||||
self.cover_url = parts[-3].split(',')[-1]+date8+parts[-2].split()[0]
|
self.cover_url = parts[-3].split(',')[-1]+date8+parts[-2].split()[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user