Skip to content

Instantly share code, notes, and snippets.

@Zitrax
Created February 7, 2013 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zitrax/4730967 to your computer and use it in GitHub Desktop.
Save Zitrax/4730967 to your computer and use it in GitHub Desktop.
Tiny python script to search for pastebin entries
import urllib2
import re
import sys
import getpass
# FILL IN
username = "test"
passwd = getpass.getpass("Enter password for %s: " % username)
realm = "test"
base_url = "http://test/"
def setup_http_auth(url):
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm=realm,
uri=url,
user=username,
passwd=passwd)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
def check_id(id):
url = "%s%s" % (base_url, id)
setup_http_auth(url)
sys.stdout.write("\rChecking %d" % id)
sys.stdout.flush()
html_content = urllib2.urlopen(url).read()
if re.search("Posted by %s" % username, html_content):
print "\nMatch for '%s'" % url
for id in range(9714,9650,-1):
check_id(id)
print "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment