pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by Daedalus on Mon 6 Apr 16:55
report abuse | View followups from Daedalus | download | new post

  1. import urllib, httplib
  2.  
  3. while 1:
  4.     query=urllib.urlencode({'q':raw_input()})
  5.  
  6.     start='<h2 class=r style="font-size:138%"><b>'
  7.     end='</b>'
  8.  
  9.     google=httplib.HTTPConnection("www.google.com")
  10.     google.request("GET","/search?"+query)
  11.     search=google.getresponse()
  12.     data=search.read()
  13.  
  14.     if data.find(start)==-1: print "Google Calculator results not found."
  15.     else:
  16.         begin=data.index(start)
  17.         result=data[begin+len(start):begin+data[begin:].index(end)]
  18.         result = result.replace("<font size=-2> </font>",",").replace(" &#215; 10<sup>","E").replace("</sup>","")
  19.         print result

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post