ajithkp560

Website Source Code Grabber

May 19th, 2012
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. #it will create source.txt in the same directory
  2.  
  3. import urllib
  4. import httplib
  5. import socket
  6.  
  7. print "\n\nWebsite Source Code Grabber"
  8. print "input URL and run it. It will Save Webpage Within Seconds"
  9.  
  10. print "\n\n\t|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
  11. print "\t|||||                                                       |||||"
  12. print "\t|||||                                                       |||||"
  13. print "\t|||||        Coded By Ajith KP:::Coded By Ajith KP          |||||"
  14. print "\t|||||                                                       |||||"
  15. print "\t||||| [email protected]         [email protected] |||||"
  16. print "\t|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
  17.  
  18. try:
  19.     url = raw_input("URL:")
  20.     url =url.replace("http://","")
  21.     txt = open('source.txt','w')
  22.     cobra = urllib.urlopen('http://'+url)
  23.     for source in cobra.readlines():
  24.         print source.rstrip()
  25.         txt.write(source.rstrip())
  26.     txt.close()
  27.     cobra.close()
  28.     raw_input('Complete: Open source.txt')
  29. except (httplib.HTTPResponse, socket.error):
  30.     print "\n\t[!] Session Cancelled; Error occured. Check internet settings"
  31. except (KeyboardInterrupt, SystemExit):
  32.     print "\t[x] Session cancelled"
Advertisement
Add Comment
Please, Sign In to add comment