Skip to content

Instantly share code, notes, and snippets.

@jollychang
Created September 7, 2011 14:20
Show Gist options
  • Save jollychang/1200690 to your computer and use it in GitHub Desktop.
Save jollychang/1200690 to your computer and use it in GitHub Desktop.
leech_from_urllib3
import os, urllib3
from BeautifulSoup import BeautifulSoup
def get_data(host, url, fields):
http_pool = urllib3.connection_from_url(host)
r = http_pool.post_url('/index.php', fields)
return r.data
def get_form(data):
#data = open('t.html', 'r')
soup = BeautifulSoup(data)
input_tags = soup.findAll('input')
D = {}
for input_tag in input_tags:
name = input_tag.get('name')
value = input_tag.get('value')
D[name] = value
return D
def get_link(data):
soup = BeautifulSoup(data)
a = soup.findAll('a')
link = a[1].getText()
return str(link)
def downloader(link, host='http://wu.gr0wl.com/index.php'):
l = link
if "wupload.com" in l:
host = 'http://wu.gr0wl.com'
elif "filesonic" in l :
host = "http://fsc.gr0wl.com"
elif "rapidshare" in l :
host = "http://rs.gr0wl.com"
elif "hotfile.com" in l :
host = "http://hf.gr0wl.com"
url = l
fields = {'link':url,'premium_acc':'on'}
data = get_data(host, url, fields)
print 'stage 1 successful'
print "*"*20
form = get_form(data)
print form
data2 = get_data(host, url, form)
print data2
link = get_link(data2)
link = "%s/dl/%s" % (host, link)
print link
os.system('wget "%s" -a urllib3.log' % link)
if __name__=='__main__':
file = open('dl.txt')
for link in file.readlines():
downloader(link)
file.close()
print "file close"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment