Update WSJ

Site appears to be in the process of transitioning to a new react based
architecture. Roll eyes.
This commit is contained in:
Kovid Goyal 2022-04-05 07:34:53 +05:30
parent f0c948eee9
commit 07480ba07c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 32 additions and 4 deletions

View File

@ -32,6 +32,19 @@ def classes(classes):
'class': lambda x: x and frozenset(x.split()).intersection(q)})
def prefixed_classes(classes):
q = frozenset(classes.split(' '))
def matcher(x):
if x:
for candidate in frozenset(x.split()):
for x in q:
if candidate.startswith(x):
return True
return False
return {'attrs': {'class': matcher}}
class WSJ(BasicNewsRecipe):
if needs_subscription:
@ -57,8 +70,9 @@ class WSJ(BasicNewsRecipe):
dict(name='span', itemprop='author', rel='author'),
dict(name='article', id='article-contents articleBody'.split()),
dict(name='div', id='article_story_body ncTitleArea snipper-ad-login'.split()),
dict(classes('nc-exp-artbody errorNotFound')),
classes('nc-exp-artbody errorNotFound'),
dict(attrs={'data-module-zone': 'article_snippet'}),
prefixed_classes('Headline__StyledHeadline- MediaLayout__Layout- ArticleByline__Container- ArticleTimestamp__Timestamp- ArticleBody__Container-'),
]
remove_tags = [
@ -288,6 +302,6 @@ class WSJ(BasicNewsRecipe):
return [
('Testing', [
{'title': 'Article One',
'url': 'https://www.wsj.com/articles/gms-plan-to-drop-chevy-cruze-hits-ohio-town-hard-1543314600'}, # noqa
'url': 'https://www.wsj.com/articles/egg-prices-jump-as-bird-flu-hits-poultry-flocks-11648900800'}, # noqa
]),
]

View File

@ -32,6 +32,19 @@ def classes(classes):
'class': lambda x: x and frozenset(x.split()).intersection(q)})
def prefixed_classes(classes):
q = frozenset(classes.split(' '))
def matcher(x):
if x:
for candidate in frozenset(x.split()):
for x in q:
if candidate.startswith(x):
return True
return False
return {'attrs': {'class': matcher}}
class WSJ(BasicNewsRecipe):
if needs_subscription:
@ -57,8 +70,9 @@ class WSJ(BasicNewsRecipe):
dict(name='span', itemprop='author', rel='author'),
dict(name='article', id='article-contents articleBody'.split()),
dict(name='div', id='article_story_body ncTitleArea snipper-ad-login'.split()),
dict(classes('nc-exp-artbody errorNotFound')),
classes('nc-exp-artbody errorNotFound'),
dict(attrs={'data-module-zone': 'article_snippet'}),
prefixed_classes('Headline__StyledHeadline- MediaLayout__Layout- ArticleByline__Container- ArticleTimestamp__Timestamp- ArticleBody__Container-'),
]
remove_tags = [
@ -288,6 +302,6 @@ class WSJ(BasicNewsRecipe):
return [
('Testing', [
{'title': 'Article One',
'url': 'https://www.wsj.com/articles/gms-plan-to-drop-chevy-cruze-hits-ohio-town-hard-1543314600'}, # noqa
'url': 'https://www.wsj.com/articles/egg-prices-jump-as-bird-flu-hits-poultry-flocks-11648900800'}, # noqa
]),
]