This commit is contained in:
WorldTeacher
2024-08-08 14:56:11 +02:00
parent fba35cdf25
commit 84689c70ed
6 changed files with 31 additions and 30 deletions

View File

@@ -68,7 +68,7 @@ class WebRequest:
return response.text
def get_data(
self,
self
):
links = self.get_book_links(self.ppn)
print(links)
@@ -83,7 +83,6 @@ class WebRequest:
item_location = location.find(
"div", class_="col-xs-12 col-md-7 col-lg-8 rds-dl-panel"
).text.strip()
print(item_location)
if f"Semesterapparat-{self.apparat}" in item_location:
pre_tag = soup.find_all("pre")
return_data = []
@@ -115,7 +114,7 @@ class BibTextTransformer:
if mode not in self.valid_modes:
logger.log_error(f"Mode {mode} not valid")
raise ValueError(f"Mode {mode} not valid")
# print(self.field)
# # print(self.field)
self.data = None
# self.bookdata = BookData(**self.data)
@@ -125,6 +124,11 @@ class BibTextTransformer:
COinS_IDENT = "ctx_ver"
BIBTEX_IDENT = "@book"
RDS_IDENT = "RDS ---------------------------------- "
if data is None:
self.data = None
return self
if self.mode == "RIS":
for line in data:
if RIS_IDENT in line:
@@ -154,8 +158,10 @@ class BibTextTransformer:
option (string, optional): Option for RDS as there are two filetypes. Use rds_availability or rds_data. Anything else gives a dict of both responses. Defaults to None.
Returns:
BookData: _description_
BookData: a dataclass containing data aboout the book
"""
if self.data is None:
return None
if self.mode == "ARRAY":
return ARRAYData().transform(self.data)
elif self.mode == "COinS":
@@ -170,7 +176,7 @@ class BibTextTransformer:
def cover(isbn):
test_url = f"https://www.buchhandel.de/cover/{isbn}/{isbn}-cover-m.jpg"
print(test_url)
# print(test_url)
data = requests.get(test_url, stream=True)
return data.content
@@ -180,22 +186,9 @@ def get_content(soup, css_class):
if __name__ == "__main__":
print("main")
link = "ZE 77000 W492"
data = WebRequest().get_ppn(link).get_data()
print(data)
# # data.get_ppn("ME 3000 S186 (2)")
# # print(data.ppn)
# # desc=data.get_data()
# # print(type(desc))
# # print(desc)
# txt = (
# BibTextTransformer("RIS")
# .get_data(WebRequest().get_ppn("ST 250 U42 (15)").get_data())
# .return_data()
# )
# print(txt)
# print(data)
# print(BibTextTransformer(data).bookdata)
# print("main")
link = "CU 8500 K64"
data = WebRequest(71).get_ppn(link).get_data()
bib = BibTextTransformer("ARRAY").get_data().return_data()
print(bib)