Wednesday, 1 October 2014

Using the urllib Module to Fetch a Remote Resource

If you want to read html content of any site or any js, css, other files also then use below code it will show all files content. Only you have to provide the url and some time if you want to read any js, css file which is present any root path then give "domain_name.com/path_of_any_file/", it will show that file content.

import urllib
import sys
f = urllib.urlopen("http://www.google.com")
while 1:
    buf = f.read(2048)
    if not len(buf):
        break
    sys.stdout.write(buf)


Thank you guys for your support.

No comments:

Post a Comment