mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-21 09:07:46 +01:00
681817ceae
GitOrigin-RevId: 83514338be1d662518bab9fe5ab6eefef98f229f
22 lines
624 B
Python
22 lines
624 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))
|