Embed in codepad.org using bash or curl

How can I embed on codepad.org from the command line using curl?

+3
source share
3 answers

here is 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
+7
source

Yes, you can do it with curl. Assuming your Python code is also in myfile.python, you can do it like this:

$ curl -d "lang=Python&submit=Submit" --data-urlencode code@myfile.py codepad.org

(Edited to make it work.)

+2
source

You can also use reval :

reval test.py
reval -l ruby -e 'p 2+2'
reval prog.hs -p # make private
0
source

Source: https://habr.com/ru/post/1732242/


All Articles