Skip to content

Commit 75d828c

Browse files
committed
Implement naive MARC fetcher
1 parent dbd7297 commit 75d828c

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
3+
from .Fetcher import Fetcher
4+
import json
5+
import pymarc
6+
7+
8+
class MarcFetcher(Fetcher):
9+
def __init__(self, params: dict[str]):
10+
super(MarcFetcher, self).__init__(params)
11+
self.url = params.get("harvest_data").get("url")
12+
13+
def build_fetch_request(self) -> dict[str]:
14+
return {"url": self.url}
15+
16+
def check_page(self, http_resp: requests.Response) -> int:
17+
return sum(1 for _ in pymarc.MARCReader(http_resp.content,
18+
to_unicode=True,
19+
utf8_handling="replace"))
20+
21+
def json(self) -> str:
22+
return json.dumps({"finished": True})
23+

metadata_fetcher/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ requests
33
sickle
44
python-dotenv
55
beautifulsoup4
6+
pymarc

0 commit comments

Comments
 (0)