----- Original Message ----- 
From: "Peter Pei" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To: <python-list@python.org>
Sent: Wednesday, December 26, 2007 8:22 PM
Subject: Re: save gb-2312 web page in a .html file


> You must be right, since I tried one page and it worked. But there is
> something wrong with this particular page:
> http://overseas.btchina.net/?categoryid=-1. When I open the saved file 
> (with
> IE7), it is all messed up.
>
>    url = 'http://overseas.btchina.net/?categoryid=-1'
>    headers = { 'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
> NT)' }
>    req = urllib2.Request(url, None, headers)
>    page = urllib2.urlopen(req).read()
>
>    htmlfile = open('btchina.html','w')
>    htmlfile.write(page)
>    htmlfile.close()
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.9/1197 - Release Date: 
> 25/12/2007 20:04
>
> 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to