fix headers for tapas requests
This commit is contained in:
parent
dfdf915b2a
commit
a4ebacb80f
@ -18,24 +18,25 @@ class TapasFeedModuleConfig(FeedModuleConfig):
|
|||||||
|
|
||||||
MODULE_NAME = 'Tapas.io comic'
|
MODULE_NAME = 'Tapas.io comic'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.session = requests.Session()
|
|
||||||
self.session.headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'}
|
|
||||||
|
|
||||||
def execute(self, bot: TeleBot, chat_id, last_id):
|
def execute(self, bot: TeleBot, chat_id, last_id):
|
||||||
config._reload_maybe()
|
config._reload_maybe()
|
||||||
|
|
||||||
if last_id is None:
|
if last_id is None:
|
||||||
last_id = 0
|
last_id = 0
|
||||||
|
|
||||||
soup = BeautifulSoup(self.session.get(f'https://tapas.io/series/{self.display_name}').text, 'html.parser')
|
soup = BeautifulSoup(requests.get(
|
||||||
|
f'https://tapas.io/series/{self.display_name}',
|
||||||
|
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'},
|
||||||
|
).text, 'html.parser')
|
||||||
for episode in soup.select('#episode-nav .episode'):
|
for episode in soup.select('#episode-nav .episode'):
|
||||||
eid = int(episode['data-eid'])
|
eid = int(episode['data-eid'])
|
||||||
if eid <= last_id:
|
if eid <= last_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
esoup = BeautifulSoup(self.session.get(f'https://tapas.io/episode/{eid}').text, 'html.parser')
|
esoup = BeautifulSoup(requests.get(
|
||||||
|
f'https://tapas.io/episode/{eid}',
|
||||||
|
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0'},
|
||||||
|
).text, 'html.parser')
|
||||||
# series_title = esoup.select_one('#series-info-wrap a.series-header-title').text
|
# series_title = esoup.select_one('#series-info-wrap a.series-header-title').text
|
||||||
title = esoup.select_one(f'#episodes [data-eid={eid}] h1').text
|
title = esoup.select_one(f'#episodes [data-eid={eid}] h1').text
|
||||||
caption = f'{title}\nhttps://tapas.io/episode/{eid}'
|
caption = f'{title}\nhttps://tapas.io/episode/{eid}'
|
||||||
|
Loading…
Reference in New Issue
Block a user