Getting source code from frames using urllib

moxie moxie_is at yahoo.com
Thu Feb 27 02:24:33 EST 2003


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




More information about the Python-list mailing list