Created
December 8, 2012 23:31
-
-
Save brookst/4242518 to your computer and use it in GitHub Desktop.
Bittorrent tracker scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Simple script to scrape a tracker""" | |
import bencode | |
import urllib2 | |
SCRAPE_URL = 'http://localhost:6969/scrape' | |
def scrape(url=SCRAPE_URL): | |
"""Return dict of scrape results""" | |
req = urllib2.Request(url) | |
res = urllib2.urlopen(req) | |
return bencode.bdecode(res.read()) | |
def print_scrape(): | |
"""Print files with pprint""" | |
from pprint import pprint | |
data = scrape() | |
files = data['files'] | |
for file_hash in files: | |
pprint(file_hash) | |
pprint(files[file_hash]) | |
if __name__ == '__main__': | |
print_scrape() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment