This commit is contained in:
Kovid Goyal 2023-10-23 13:12:35 +05:30
parent 74bb2c4c9d
commit f316dea0ad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -10,6 +10,7 @@ from base64 import standard_b64encode
from datetime import date, timedelta from datetime import date, timedelta
from mechanize import Request from mechanize import Request
from calibre.ptempfile import PersistentTemporaryFile
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
from css_selectors import Select from css_selectors import Select
@ -22,12 +23,9 @@ try:
except ImportError: except ImportError:
from urllib import quote from urllib import quote
from calibre.scraper.simple import read_url
from calibre.ptempfile import PersistentTemporaryFile
needs_subscription = False needs_subscription = False
class WSJ(BasicNewsRecipe): class WSJ(BasicNewsRecipe):
if needs_subscription: if needs_subscription:
@ -52,7 +50,7 @@ class WSJ(BasicNewsRecipe):
extra_css = ''' extra_css = '''
#big-top-caption { font-size:small; text-align:center; } #big-top-caption { font-size:small; text-align:center; }
[data-type:"tagline"] { font-style:italic; color:#202020; } [data-type:"tagline"], em { font-style:italic; color:#202020; }
.auth { font-size:small; } .auth { font-size:small; }
.sub, em, i { color: #202020; } .sub, em, i { color: #202020; }
''' '''
@ -75,6 +73,7 @@ class WSJ(BasicNewsRecipe):
articles_are_obfuscated = True articles_are_obfuscated = True
def get_obfuscated_article(self, url): def get_obfuscated_article(self, url):
from calibre.scraper.simple import read_url
br = self.get_browser() br = self.get_browser()
br.set_handle_redirect(False) br.set_handle_redirect(False)
try: try:
@ -116,7 +115,6 @@ class WSJ(BasicNewsRecipe):
parent['class'] = 'auth' parent['class'] = 'auth'
return soup return soup
# login {{{ # login {{{
def get_browser_for_wsj(self, *a, **kw): def get_browser_for_wsj(self, *a, **kw):
@ -126,7 +124,7 @@ class WSJ(BasicNewsRecipe):
br.set_cookie('ccpaApplies', 'false', '.wsj.com') br.set_cookie('ccpaApplies', 'false', '.wsj.com')
return br return br
if needs_subscription: if False and needs_subscription: # disabled as we currently use archive.is
def get_browser(self, *a, **kw): def get_browser(self, *a, **kw):
from pprint import pprint from pprint import pprint
pprint pprint