Chinaunix首页 | 论坛 | 博客
  • 博客访问: 111154
  • 博文数量: 49
  • 博客积分: 2612
  • 博客等级: 少校
  • 技术积分: 431
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-01 14:31
个人简介

来来去去

文章分类

全部博文(49)

文章存档

2015年(1)

2012年(4)

2011年(1)

2010年(42)

2009年(1)

我的朋友

分类: Python/Ruby

2010-05-24 17:05:33

import urllib2
import filecmp

def url_open(url):
    response=urllib2.urlopen(url)
    html=response.read()
    f=open('f:\python\url_open.txt','w')
    f.write(html)
    f.close()

def url_request(url):
    req=urllib2.Request(url)
    response=urllib2.urlopen(req)
    the_page=response.read()
    f=open('f:\python\url_request.txt','w')
    f.write(the_page)
    f.close

def compare():
    return filecmp.cmp(r'f:\python\url_open.txt',r'f:\python\url_request.txt')
    

if __name__=='__main__':
    url=""
    url_open(url)
    url_request(url)
    res=compare()
    print res

Compare the difference of the file get by using request and using urlopen directly.

阅读(731) | 评论(0) | 转发(0) |
0

上一篇:重命名文件

下一篇:登入 人人网

给主人留下些什么吧!~~