Skip to content

Commit

Permalink
Implement naive MARC fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
lthurston committed Dec 17, 2023
1 parent 7d9f7e3 commit db952f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions metadata_fetcher/fetchers/marc_fetcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests

from .Fetcher import Fetcher
import json
import pymarc


class MarcFetcher(Fetcher):
def __init__(self, params: dict[str]):
super(MarcFetcher, self).__init__(params)
self.url = params.get("harvest_data").get("url")

def build_fetch_request(self) -> dict[str]:
return {"url": self.url}

def check_page(self, http_resp: requests.Response) -> int:
return sum(1 for _ in pymarc.MARCReader(http_resp.content,
to_unicode=True,
utf8_handling="replace"))

def json(self) -> str:
return json.dumps({"finished": True})

1 change: 1 addition & 0 deletions metadata_fetcher/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ requests
sickle
python-dotenv
beautifulsoup4
pymarc

0 comments on commit db952f0

Please sign in to comment.