Getting source code from frames using urllib

Chen chenpuqing at 163.net
Thu Feb 27 02:36:52 EST 2003


"moxie" <moxie_is at yahoo.com> wrote in message
news:b1078faa.0302262324.7caf673d at posting.google.com...
> My current problem is trying to figure out how to retrieve the source
> code of a webpage that uses frames.
>
> Here's a simple example of how to get the source code of
> http://www.google.com
>
> ----------------------------
> #!/usr/bin/env python
> import urllib
>
> url = "http://www.google.com"
> web = urllib.urlopen(url)
> html = web.read()
> print html
> ----------------------------
>
> However let's say you have a page called blah.html that uses frames.
> So the html code that is retrieve is something like:
>
> <html><head><title>Some title </title></head>
> <frameset rows='120,*' border='5' frameborder='5' framespacing='5'>
> <frame name='top' src='top.html' scrolling='no'>
> ...
> ...
>
> How would I, using this example get the html source of the frame named
> 'top'(top.html)
>
>
> Chris Jackson

The frame has its own url. It's top.html, in this example and lies at the
same directory of the total page.







More information about the Python-list mailing list