NEWB problem with urllib2

Penn powderdrop at
Tue Nov 10 02:48:01 CET 2009

Thanks Simon!

You are right.. I also believe it is something with Eclipse.

I've been working since... the module below runs.. but Eclipse is
still showing an error when I reference urlopen with a little red X...
saying it is an undefined variable in the IDE.. but not giving me an
runtime errors.

from urllib2 import *

def openfilereadaline(a):

    f = open(a)
    print f
    for line in f:
        print line.rstrip()

def openWebSite(a):

    ur = urlopen(a) #open url
    contents = ur.readlines()#readlines from url file
    fo = open("test.txt", "w")#open test.txt
    for line in contents:
        print "writing %s to a file" %(line,)
        fo.write(line)#write lines from url file to text file
    fo.close()#close text file

if __name__ == '__main__':


    print "Hello World"

More information about the Python-list mailing list