diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-19 20:13:13 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-19 20:13:13 +0100 |
commit | 78f50ab8b4bd57cd67d015fa2608bc86b116dfba (patch) | |
tree | 4a4d943bffe0eeab63be12d7e91b1d79e60db591 /skripti | |
parent | rš cv (diff) | |
download | r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar.gz r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar.bz2 r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar.lz r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar.xz r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.tar.zst r-78f50ab8b4bd57cd67d015fa2608bc86b116dfba.zip |
Diffstat (limited to 'skripti')
-rwxr-xr-x | skripti/4chan-thread-dl.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/skripti/4chan-thread-dl.py b/skripti/4chan-thread-dl.py index 7a71df2..f1e2717 100755 --- a/skripti/4chan-thread-dl.py +++ b/skripti/4chan-thread-dl.py @@ -6,6 +6,12 @@ if len(argv) != 3: raise Exception("prvi arg je url do threada, drugi arg je končnica, recimo .webm") s = BeautifulSoup(get(argv[1]).content, "html.parser") for a in s.find_all("a"): - if a.attrs["href"].endswith(argv[2]) and "title" in a.attrs and "/" not in a.attrs["title"]: - print(a.attrs["title"]) - open(a.attrs["title"], "wb").write(get("http:" + a.attrs["href"]).content) + if a.attrs["href"].endswith(argv[2]): + fn = None + if "title" in a.attrs and "/" not in a.attrs["title"]: + fn = a.attrs["title"] + elif "/" not in a.getText() and ("class" not in a.attrs or "fileThumb" not in a.attrs["class"]): + fn = a.getText() + if fn is not None: + print(fn) + open(fn, "wb").write(get("http:" + a.attrs["href"]).content) |