py3: Port use of cookielib in recipes

This commit is contained in:
Kovid Goyal 2019-04-01 14:30:30 +05:30
parent 972d98302e
commit 4b0ed2ab99
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 20 additions and 8 deletions

View File

@ -9,7 +9,10 @@ discovermagazine.com
'''
import re
import json
import cookielib
try:
from http.cookiejar import Cookie
except ImportError:
from cookielib import Cookie
import mechanize
from calibre.web.feeds.news import BasicNewsRecipe
@ -55,7 +58,7 @@ class DiscoverMagazine(BasicNewsRecipe):
if hasattr(br, 'set_cookie'):
br.set_cookie('KSERV', session_id, 'discovermagazine.com')
else:
c = cookielib.Cookie(
c = Cookie(
None, 'KSERV', session_id,
None, False,
'discovermagazine.com', True, False,

View File

@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
economist.com
'''
import cookielib
try:
from http.cookiejar import Cookie
except ImportError:
from cookielib import Cookie
from collections import OrderedDict
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe):
br = BasicNewsRecipe.get_browser(self)
# Add a cookie indicating we have accepted Economist's cookie
# policy (needed when running from some European countries)
ck = cookielib.Cookie(
ck = Cookie(
version=0,
name='notice_preferences',
value='2:',

View File

@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
economist.com
'''
import cookielib
try:
from http.cookiejar import Cookie
except ImportError:
from cookielib import Cookie
from collections import OrderedDict
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe):
br = BasicNewsRecipe.get_browser(self)
# Add a cookie indicating we have accepted Economist's cookie
# policy (needed when running from some European countries)
ck = cookielib.Cookie(
ck = Cookie(
version=0,
name='notice_preferences',
value='2:',

View File

@ -1,5 +1,8 @@
from calibre.web.feeds.news import BasicNewsRecipe
import cookielib
try:
from http.cookiejar import Cookie
except ImportError:
from cookielib import Cookie
class BasicUserRecipe1333905513(BasicNewsRecipe):
@ -15,7 +18,7 @@ class BasicUserRecipe1333905513(BasicNewsRecipe):
br = BasicNewsRecipe.get_browser(self)
# Add a cookie indicating we have accepted the cookie
# policy
ck = cookielib.Cookie(
ck = Cookie(
version=0, name='nl_cookiewall_version', value='1', port=None,
port_specified=False, domain='.trouw.nl',
domain_specified=False, domain_initial_dot=True, path='/',