[Tutor] (no subject)

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 27 Mar 2001 18:23:08 -0800 (PST)


On Wed, 28 Mar 2001, wong chow cheok wrote:

> hai. I am a student currently doing training and am using python. i ahve 
> this problem. i am trying yo open the source code for a page and extract 
> certain information on it for example : the temperature for the day and the 
> title of the page.
> 
> >>>import urllib
> >>>f=urllib.urlopen("http://www.kjc.gov.my/cgi-bin/fcastdisplay.cgi?lang=EN")
> >>>print f.read()

> this is the program but whenever i try to enter parameters it still
> outputs the whole source code. how do i do it?

The last command:

    print f.read()

is responsible for printing out the whole source.  Instead of printing it,
it sounds like you'll want to process it instead.  Try something like:

    source = f.read()

Then you'll have the whole html in your source variable, and you'll be
able to manipulate it.

How do you plan to extract the temperature or title from the source code?