File size: 1,251 Bytes
d49ec91 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # code by Sett Sarverott A.A.B. @ 2026
# Inceptorium Apokryf for SJP
# on terms of license GNU GPL 2.0
from huggingface_hub import login, upload_folder
import requests
import bs4
import markdownify
import zipfile
import urllib
import json
sjpUrl = "https://sjp.pl/sl/odmiany/"
sourceserver = requests.get(sjpUrl)
with open("./sjp.pl_sl_odmiany.md", "w") as sjpPage:
sjpPage.write(markdownify.markdownify(sourceserver.text))
webpage = bs4.BeautifulSoup(sourceserver.text)
links = list()
for link in webpage.find_all("a"):
print(link)
try:
links.append([
link.string,
urllib.parse.urljoin(sjpUrl, str(link.get("href")))
])
except Exception as error:
print("ERROR:", error)
with open("./links.json", "w") as sjpPage:
sjpPage.write(json.dumps(links))
print(links)
for link in links:
print("ZIPTEST", link[1][-4:], link[1][-4:]==".zip")
if link[1][-4:]==".zip":
sjpDownload = requests.get(link[1])
with open("./sjp.zip", 'wb') as fd:
for chunk in sjpDownload.iter_content(chunk_size=128):
fd.write(chunk)
# print(zipfile.ZipInfo("./sjp.zip"))
zipfile.ZipFile("./sjp.zip").extractall()
login()
upload_folder(
folder_path=".",
repo_id="Apokryf/SJP",
repo_type="dataset"
) |