Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SACHA txt Downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Petz
SACHA txt Downloader
Commits
b1ce712a
Commit
b1ce712a
authored
4 years ago
by
Georg Petz
Browse files
Options
Downloads
Patches
Plain Diff
add mybinder
parent
1bcee365
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
txtDownloader.ipynb
+12
-6
12 additions, 6 deletions
txtDownloader.ipynb
with
13 additions
and
6 deletions
README.md
0 → 100644
+
1
−
0
View file @
b1ce712a
[

](https://mybinder.org/v2/git/https%3A%2F%2Flabs.onb.ac.at%2Fgitlab%2Fgeorgp%2Fsacha-txt-downloader/HEAD?filepath=txtDownloader.ipynb)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
txtDownloader.ipynb
+
12
−
6
View file @
b1ce712a
...
...
@@ -2,16 +2,16 @@
"cells": [
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
1
,
"metadata": {},
"outputs": [],
"source": [
"import urllib.request, json"
"import urllib.request, json
, shutil
"
]
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
2
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count":
46
,
"execution_count":
3
,
"metadata": {},
"outputs": [
{
...
...
@@ -50,9 +50,15 @@
"response = urllib.request.urlopen(url)\n",
"data = json.loads(response.read())\n",
"\n",
"i=0\n",
"\n",
"for page in data[\"sequences\"][0][\"canvases\"]:\n",
" txt_url = page[\"otherContent\"][0][\"resources\"][0][\"resource\"][\"@id\"]\n",
" print(txt_url)"
" i=i+1\n",
" print(txt_url)\n",
" output_file = str(i)+\".txt\"\n",
" with urllib.request.urlopen(txt_url) as response, open(output_file, 'wb') as out_file:\n",
" shutil.copyfileobj(response, out_file)"
]
},
{
...
...
@@ -79,7 +85,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6
.5"
"version": "3.
8
.5"
}
},
"nbformat": 4,
...
...
%% Cell type:code id: tags:
```
python
import
urllib.request
,
json
import
urllib.request
,
json
,
shutil
```
%% Cell type:code id: tags:
```
python
url
=
"
https://iiif.onb.ac.at/presentation/ABO/+Z196807705/manifest/
"
```
%% Cell type:code id: tags:
```
python
response
=
urllib
.
request
.
urlopen
(
url
)
data
=
json
.
loads
(
response
.
read
())
i
=
0
for
page
in
data
[
"
sequences
"
][
0
][
"
canvases
"
]:
txt_url
=
page
[
"
otherContent
"
][
0
][
"
resources
"
][
0
][
"
resource
"
][
"
@id
"
]
i
=
i
+
1
print
(
txt_url
)
output_file
=
str
(
i
)
+
"
.txt
"
with
urllib
.
request
.
urlopen
(
txt_url
)
as
response
,
open
(
output_file
,
'
wb
'
)
as
out_file
:
shutil
.
copyfileobj
(
response
,
out_file
)
```
%% Output
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000001.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000002.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000003.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000004.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000005.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000006.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000007.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000008.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000009.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000010.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000011.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000012.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000013.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000014.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000015.txt
https://iiif.onb.ac.at/presentation/ABO/Z196807705/resource/00000016.txt
%% Cell type:code id: tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment