Python Forum
send file to codepad
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
send file to codepad
#1
Ive used this script for years....havent even bothered to update it. 

import urllib
import urllib2
import sys

'''
send argv[1] file to codepad for quick show help
'''

url = 'http://codepad.org'
content=open(sys.argv[1]).read()
values = {'lang' : 'Python',
          'code' : content,
          'submit':'Submit'}

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
for href in the_page.split("</a>"):
    if "Link:" in href:
        ind=href.index('Link:')
        found = href[ind+5:]
        for i in found.split('">'):
            if '<a href=' in i:
                 print "The link: " ,i.replace('<a href="',"").strip()
Output:
metulburr@ubuntu:/$ python codepad.py etc/fstab The link:  http://codepad.org/UVE0nFPD
Recommended Tutorials:
Reply
#2
Do you have a Github link to it?
Reply
#3
apparently i did not put this to my github at all. But i will now.
https://github.com/metulburr/random/blob...codepad.py

Or do you mean to upload your file to github gist?
Recommended Tutorials:
Reply
#4
I meant the source code on Github, but a Gist is a good idea too :)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020