Monday, April 18, 2011

Python script to get the webpage source

Here is the python script to get the source code of any web page..all you need is to edit the url in the script.

import urllib

filehandle = urllib.urlopen('http://www.techyupdates.blogspot.com')

for lines in filehandle.readlines():
   print lines

filehandle.close()

10 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Athentha kiraninte comment remove cheythath?
    BTW, Let me suggest an alternative method. Open the webpage in a browser. Right click, and select view page source. It's easier than editing and running a python script, and believe me, it really works.

    ReplyDelete
    Replies
    1. Excellent @Anees You are really cool LMAO

      Delete
  3. wow Anees we dint know that....ROFL...:))),, so everyone should stop coding ...lol

    ReplyDelete
  4. Last but but not the least,,, IT DOES REALLY WORK ...ROFL>>>:))))))) .

    ReplyDelete
  5. Koi hai yahan.... Hello...!!!!

    ReplyDelete
  6. What is the purpose of the filehandle.close() line? I ran the script without this line and it seemed to work fine. I'm a newb: thanks for explaining.

    ReplyDelete

  7. It is really a nice and helpful piece of info. I’m glad that you simply shared this helpful info with us. Please keep us
    informed like this. Thank you for sharing.
    web designing companies

    ReplyDelete
  8. Your script is simple and so useful - thanks a ton. And to answer Anees, sometimes people want to automate things. Sometimes those things are very big, made up of smaller, repetetive things like downloading files. This script will allow me to hit an FTP site, download it source and determine the name of a file I want to download.

    ReplyDelete