Skip to content
Snippets Groups Projects
Commit 55fb76e3 authored by Georg Petz's avatar Georg Petz
Browse files

update

parent c744aba2
Branches
No related tags found
No related merge requests found
venv/
%% Cell type:code id: tags:
``` python
import urllib.request, json, shutil, os
from zipfile import ZipFile
from IPython.display import FileLink
```
%% Cell type:markdown id: tags:
e.g.:+Z196807705
Insert a Barcode from the ABO project into the input box, e.g.:+Z196807705.
%% Cell type:code id: tags:
``` python
barcode=input()
url="https://iiif.onb.ac.at/presentation/ABO/"+barcode+"/manifest/"
print ("URL of the IIIF Manifest: " + url)
```
%% Output
+Z196807705
URL of the IIIF Manifest: https://iiif.onb.ac.at/presentation/ABO/+Z196807705/manifest/
%% Cell type:code id: tags:
``` python
url="https://iiif.onb.ac.at/presentation/ABO/"+barcode+"/manifest/"
url
```
%% Output
%% Cell type:markdown id: tags:
'https://iiif.onb.ac.at/presentation/ABO/+Z196807705/manifest/'
Click on {Barcode}.zip to actually download the zip to your computer.
%% Cell type:code id: tags:
``` python
response = urllib.request.urlopen(url)
data = json.loads(response.read())
i=0
zipObj = ZipFile(barcode + ".zip", "w")
all_txt = open("all.txt","wb")
for page in data["sequences"][0]["canvases"]:
txt_url = page["otherContent"][0]["resources"][0]["resource"]["@id"]
i=i+1
print("downloading " + txt_url)
output_file = str(i) + ".txt"
output_file = str(txt_url.split('/')[-1])
with urllib.request.urlopen(txt_url) as response, open(output_file, "wb") as out_file:
shutil.copyfileobj(response, out_file)
zipObj.write(os.path.abspath(output_file),output_file)
txt_page = open(output_file, "rb")
shutil.copyfileobj(txt_page, all_txt)
txt_page.close
os.remove(output_file)
zipObj.write("all.txt")
all_txt.close()
os.remove("all.txt")
zipObj.close()
FileLink(barcode + ".zip")
```
%% Output
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000001.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000002.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000003.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000004.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000005.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000006.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000007.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000008.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000009.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000010.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000011.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000012.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000013.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000014.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000015.txt
downloading https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000016.txt
/home/georg/Projekte/sacha/sacha-txt-downloader/+Z196807705.zip
C:\Projekte\sacha-txt-downloader\+Z196807705.zip
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment