/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Snippler - getCode() # snipplr # Author : Abhinay Omkar import re,urllib2,sys # input url = "http://snipplr.com/view/8/ajax-edit-in-place/" try: inurl = sys.argv[1] except: print "Err: url is missing." sys.exit() try: path = sys.argv[2] except: path = inurl.split('/')[-2] num = re.sub(r'[a-zA-Z/:\-.]*','',inurl) url = "http://snipplr.com/view.php?codeview&id="+num raw = repr(urllib2.urlopen(url).read()) prog = re.compile(r'<textarea rows="25">(.*)</textarea>').search(raw).group() open prog = prog.replace('\\r\\n','\n').replace('\\t',' ')[20:-11] print "File "+path+" Opened..." print prog open(path,'w').write(prog)
Comments
