hyperboria/nexus/pylon/sources/specific/nejm.py
the-superpirate 7389f85ef2 - Send Pylon to golden
-  Move fancy naming to Hub
-  Adopt translations
-  Fix long authors list in bot
-  Support CJK in scitech
-  Fixed pylon bug with decoding improper unicode ch...

GitOrigin-RevId: 74f73c44f749a71cb65dd5ddd3416f32a83d329f
2021-01-08 23:09:19 +03:00

22 lines
623 B
Python

from typing import AsyncIterable
from nexus.pylon.sources.base import (
DoiSource,
PreparedRequest,
)
class NejmSource(DoiSource):
base_url = 'https://www.nejm.org'
resolve_timeout = 10
use_proxy = False
async def resolve(self) -> AsyncIterable[PreparedRequest]:
async with self.get_resolve_session() as session:
url = f'{self.base_url}/doi/pdf/{self.doi}'
async with session.get(
url,
timeout=self.resolve_timeout
) as resp:
yield PreparedRequest(method='get', cookies=resp.cookies, url=str(resp.url))