Parsing data from URL

Harlin Seritt harlinseritt at yahoo.com
Sun Apr 24 20:24:18 EDT 2005


I am trying to do the following:

<of course website.com is not the actual site>

import urllib

url = 'http://www.website.com/file.shtml'
dat = urllib.urlopen(url, 'r').read()
print dat

When I do so, I get the following data:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL <P>
<HR>
<ADDRESS>Apache/1.3.27 Server at website.com Port 80</ADDRESS>
</BODY></HTML>

How can I make sure that I get the actual html data instead of the data
from redirected URL?

thanks,

Harlin




More information about the Python-list mailing list