Skip to content

Instantly share code, notes, and snippets.

@MCOfficer
Last active November 14, 2020 13:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MCOfficer/1cd9afcd370694c9a054c2a3a69e75e2 to your computer and use it in GitHub Desktop.
Save MCOfficer/1cd9afcd370694c9a054c2a3a69e75e2 to your computer and use it in GitHub Desktop.
OpenDirectoryDownloader batch scanning
# Reads URLs from to_scan.txt, one URL per line.
# Outputs the reddit-formatted results to results.txt
import subprocess
import os
with open("to_scan.txt", "r") as f:
urls = [line.strip() for line in f.readlines()]
print("Scanning %s URLs" % len(urls))
print("Removing History.log")
os.remove("History.log")
print("Clearing results.txt")
os.remove("results.txt")
for url in urls:
subprocess.run(["./OpenDirectoryDownloader", "-u", url, "-l", "-s", "-q"])
with open("History.log", "r") as f:
lines = ""
for line in f.readlines():
if line.startswith("|") or line.startswith("\n"):
lines += line
lines += "\n^(Created by [KoalaBear84's OpenDirectory Indexer](https://github.com/KoalaBear84/OpenDirectoryDownloader/))"
with open("results.txt", "a") as f:
f.write(lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment