Python : Opening A URL

by bitznbitez

Doing some quick and dirty coding in Python tonight.    Compared to java I usually prefer doing things in python.    Here is one example….  Opening a URL

import urllib

filehandle = urllib.urlopen('http://cnn.com/')

for lines in filehandle.readlines():
    print lines

filehandle.close()

Naturally this code segment doesn’t do anything besides print the HTML out but you get the idea……

Advertisements