Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
Created June 22, 2012 09:54
Show Gist options
  • Save DamianZaremba/2971763 to your computer and use it in GitHub Desktop.
Save DamianZaremba/2971763 to your computer and use it in GitHub Desktop.
Horrid depython.com client
#!/usr/bin/env python
import os
import sys
import requests
from BeautifulSoup import BeautifulSoup
try:
file_path = sys.argv[1]
except:
print "Usage: %s <file path>" % sys.argv[0]
sys.exit()
if not os.path.isfile(file_path):
print "Specified file isn't a file!"
sys.exit()
fh = open(file_path)
request = requests.post(
url='http://www.depython.com/index.php',
files = {'userfile': fh}
)
soup = BeautifulSoup(request.text)
ta = soup.findAll('textarea')[0]
lines = ta.contents[0].split("\n")
print "\n".join(lines[:-3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment