Search code examples
bashcurlpastebin

Paste to codepad.org using bash or curl


How can I paste to codepad.org from the commandline using curl?


Solution

  • here's a Python script

    import urllib
    import urllib2
    url = 'http://codepad.org'
    content=open("myscript.py").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

    $ python python.py
    The link:  http://codepad.org/W0G8HIzM