Skip to content

Instantly share code, notes, and snippets.

@paradoxxxzero
Created April 4, 2012 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paradoxxxzero/2300026 to your computer and use it in GitHub Desktop.
Save paradoxxxzero/2300026 to your computer and use it in GitHub Desktop.
Offliberpy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2012 paradoxxx_zero
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
import sys
from urllib.request import urlopen
from urllib.parse import urlencode
from re import search
post_url = "http://offliberty.com/off.php"
def parse_response(response):
return search(b'<A HREF="(.*)" class="download"', response).group(1)
def get_response(url):
return urlopen(
post_url,
urlencode({
'track': url,
'reftext': ''}).encode('utf-8')).read()
def offliberpy(url):
return parse_response(get_response(url))
if __name__ == '__main__':
print(offliberpy(sys.argv[1]).decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment