mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Port use of cookielib in recipes
This commit is contained in:
parent
972d98302e
commit
4b0ed2ab99
@ -9,7 +9,10 @@ discovermagazine.com
|
|||||||
'''
|
'''
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import cookielib
|
try:
|
||||||
|
from http.cookiejar import Cookie
|
||||||
|
except ImportError:
|
||||||
|
from cookielib import Cookie
|
||||||
import mechanize
|
import mechanize
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ class DiscoverMagazine(BasicNewsRecipe):
|
|||||||
if hasattr(br, 'set_cookie'):
|
if hasattr(br, 'set_cookie'):
|
||||||
br.set_cookie('KSERV', session_id, 'discovermagazine.com')
|
br.set_cookie('KSERV', session_id, 'discovermagazine.com')
|
||||||
else:
|
else:
|
||||||
c = cookielib.Cookie(
|
c = Cookie(
|
||||||
None, 'KSERV', session_id,
|
None, 'KSERV', session_id,
|
||||||
None, False,
|
None, False,
|
||||||
'discovermagazine.com', True, False,
|
'discovermagazine.com', True, False,
|
||||||
|
@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
'''
|
'''
|
||||||
economist.com
|
economist.com
|
||||||
'''
|
'''
|
||||||
import cookielib
|
try:
|
||||||
|
from http.cookiejar import Cookie
|
||||||
|
except ImportError:
|
||||||
|
from cookielib import Cookie
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
||||||
@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe):
|
|||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
# Add a cookie indicating we have accepted Economist's cookie
|
# Add a cookie indicating we have accepted Economist's cookie
|
||||||
# policy (needed when running from some European countries)
|
# policy (needed when running from some European countries)
|
||||||
ck = cookielib.Cookie(
|
ck = Cookie(
|
||||||
version=0,
|
version=0,
|
||||||
name='notice_preferences',
|
name='notice_preferences',
|
||||||
value='2:',
|
value='2:',
|
||||||
|
@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
'''
|
'''
|
||||||
economist.com
|
economist.com
|
||||||
'''
|
'''
|
||||||
import cookielib
|
try:
|
||||||
|
from http.cookiejar import Cookie
|
||||||
|
except ImportError:
|
||||||
|
from cookielib import Cookie
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
||||||
@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe):
|
|||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
# Add a cookie indicating we have accepted Economist's cookie
|
# Add a cookie indicating we have accepted Economist's cookie
|
||||||
# policy (needed when running from some European countries)
|
# policy (needed when running from some European countries)
|
||||||
ck = cookielib.Cookie(
|
ck = Cookie(
|
||||||
version=0,
|
version=0,
|
||||||
name='notice_preferences',
|
name='notice_preferences',
|
||||||
value='2:',
|
value='2:',
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
import cookielib
|
try:
|
||||||
|
from http.cookiejar import Cookie
|
||||||
|
except ImportError:
|
||||||
|
from cookielib import Cookie
|
||||||
|
|
||||||
|
|
||||||
class BasicUserRecipe1333905513(BasicNewsRecipe):
|
class BasicUserRecipe1333905513(BasicNewsRecipe):
|
||||||
@ -15,7 +18,7 @@ class BasicUserRecipe1333905513(BasicNewsRecipe):
|
|||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
# Add a cookie indicating we have accepted the cookie
|
# Add a cookie indicating we have accepted the cookie
|
||||||
# policy
|
# policy
|
||||||
ck = cookielib.Cookie(
|
ck = Cookie(
|
||||||
version=0, name='nl_cookiewall_version', value='1', port=None,
|
version=0, name='nl_cookiewall_version', value='1', port=None,
|
||||||
port_specified=False, domain='.trouw.nl',
|
port_specified=False, domain='.trouw.nl',
|
||||||
domain_specified=False, domain_initial_dot=True, path='/',
|
domain_specified=False, domain_initial_dot=True, path='/',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user