This commit is contained in:
Kovid Goyal 2024-12-11 10:44:11 +05:30
commit 71d5a6049b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 18 additions and 13 deletions

View File

@ -4,6 +4,7 @@
import json import json
import re import re
import time import time
from uuid import uuid4
from collections import defaultdict from collections import defaultdict
from datetime import datetime, timedelta from datetime import datetime, timedelta
from urllib.parse import quote, urlencode from urllib.parse import quote, urlencode
@ -254,10 +255,9 @@ class Economist(BasicNewsRecipe):
) )
br = BasicNewsRecipe.get_browser(self, *args, **kwargs) br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
else: else:
# Needed to bypass cloudflare kwargs['user_agent'] = 'TheEconomist-Lamarr-android'
kwargs['user_agent'] = 'common_words/based'
br = BasicNewsRecipe.get_browser(self, *args, **kwargs) br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
br.addheaders += [('Accept-Language', 'en-GB,en-US;q=0.9,en;q=0.8')] br.addheaders += [('x-request-id', str(uuid4()))]
return br return br
def publication_date(self): def publication_date(self):
@ -525,7 +525,9 @@ class Economist(BasicNewsRecipe):
feeds = [] feeds = []
for part in safe_dict(data, "props", "pageProps", "content", "sections"): for part in safe_dict(
data, "props", "pageProps", "content", "headerSections"
) + safe_dict(data, "props", "pageProps", "content", "sections"):
section = safe_dict(part, "name") or '' section = safe_dict(part, "name") or ''
if not section: if not section:
continue continue

View File

@ -4,6 +4,7 @@
import json import json
import re import re
import time import time
from uuid import uuid4
from collections import defaultdict from collections import defaultdict
from datetime import datetime, timedelta from datetime import datetime, timedelta
from urllib.parse import quote, urlencode from urllib.parse import quote, urlencode
@ -254,10 +255,9 @@ class Economist(BasicNewsRecipe):
) )
br = BasicNewsRecipe.get_browser(self, *args, **kwargs) br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
else: else:
# Needed to bypass cloudflare kwargs['user_agent'] = 'TheEconomist-Lamarr-android'
kwargs['user_agent'] = 'common_words/based'
br = BasicNewsRecipe.get_browser(self, *args, **kwargs) br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
br.addheaders += [('Accept-Language', 'en-GB,en-US;q=0.9,en;q=0.8')] br.addheaders += [('x-request-id', str(uuid4()))]
return br return br
def publication_date(self): def publication_date(self):
@ -525,7 +525,9 @@ class Economist(BasicNewsRecipe):
feeds = [] feeds = []
for part in safe_dict(data, "props", "pageProps", "content", "sections"): for part in safe_dict(
data, "props", "pageProps", "content", "headerSections"
) + safe_dict(data, "props", "pageProps", "content", "sections"):
section = safe_dict(part, "name") or '' section = safe_dict(part, "name") or ''
if not section: if not section:
continue continue

View File

@ -3,6 +3,7 @@
import json import json
import time import time
from uuid import uuid4
from datetime import datetime, timedelta from datetime import datetime, timedelta
from urllib.parse import quote, urlencode from urllib.parse import quote, urlencode
@ -191,10 +192,9 @@ class EconomistNews(BasicNewsRecipe):
self.oldest_article = float(d) self.oldest_article = float(d)
def get_browser(self, *args, **kwargs): def get_browser(self, *args, **kwargs):
# Needed to bypass cloudflare kwargs['user_agent'] = 'TheEconomist-Lamarr-android'
kwargs['user_agent'] = 'common_words/based'
br = BasicNewsRecipe.get_browser(self, *args, **kwargs) br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
br.addheaders += [('Accept-Language', 'en-GB,en-US;q=0.9,en;q=0.8')] br.addheaders += [('x-request-id', str(uuid4()))]
return br return br
def economist_return_index(self, ans): def economist_return_index(self, ans):

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- #!/usr/bin/env python
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
@ -7,6 +7,7 @@ class BasicUserRecipe1318619728(BasicNewsRecipe):
oldest_article = 7 oldest_article = 7
max_articles_per_feed = 100 max_articles_per_feed = 100
auto_cleanup = True auto_cleanup = True
language = 'fr'
feeds = [(u'Korben', u'http://feeds2.feedburner.com/KorbensBlog-UpgradeYourMind')] feeds = [(u'Korben', u'http://feeds2.feedburner.com/KorbensBlog-UpgradeYourMind')]

View File

@ -7,7 +7,7 @@ from calibre.web.feeds.news import BasicNewsRecipe
class Ugeskriftet(BasicNewsRecipe): class Ugeskriftet(BasicNewsRecipe):
title = 'Ugeskriftet' title = 'Ugeskriftet'
description = 'Ugeskriftet for læger' description = 'Ugeskriftet for læger'
language = 'dan' language = 'da'
__author__ = 'https://github.com/morusn' __author__ = 'https://github.com/morusn'
oldest_article = 7 oldest_article = 7
publication_type = 'magazine' publication_type = 'magazine'