import sys, urllib2
# req = urllib2.Request(sys.argv[1])
req = urllib2.Request('http://www.sina.com.cn')
fd = urllib2.urlopen(req)
print "Retrieved", fd.geturl()
info = fd.info()
for key, value in info.items():
print "%s = %s" % (key, value)

结果如下:

Retrieved http://www.sina.com.cn
content-length = 117199
x-cache = HIT from cnc.sy.1cf2.32.spool.sina.com.cn
x-powered-by = shci_v1.03
content-encoding = gzip
age = 3
expires = Mon, 28 Dec 2015 13:59:14 GMT
vary = Accept-Encoding
server = nginx
last-modified = Mon, 28 Dec 2015 13:57:24 GMT
connection = close
cache-control = max-age=60
date = Mon, 28 Dec 2015 13:58:14 GMT
content-type = text/html

Python获取web页面信息的更多相关文章

  1. 开源 java CMS - FreeCMS2.3 Web页面信息採集

    原文地址:http://javaz.cn/site/javaz/site_study/info/2015/23312.html 项目地址:http://www.freeteam.cn/ Web页面信息 ...

  2. C# -- WebClient自动获取web页面编码并转换

    C# -- WebClient自动获取web页面编码并转换 抽个时间,写篇小文章,最近有个朋友,用vb开发一个工具,遇到WebClient获取的内容出现乱码,可惜对vb不是很熟悉,看了几分钟vb的语法 ...

  3. Python 获取CentOS主机信息

    Python 获取主机IP地址 #!/usr/bin/env python #coding:utf-8 import os ip=os.popen("ifconfig eth0|grep ' ...

  4. 在页面上获取web项目信息

    获取协议名称:request.getScheme() 获取域名:request.getServerName() 获取项目名称:request.getContextPath() 使用EL表达式获取项目名 ...

  5. 我了解到的新知识之----如何使用Python获取最新外汇汇率信息

    这个需求本来是来源于公司同事工作中需求,用户需要使用数据分析工具Power BI抓取多页的中国银行官网上当天的外汇数据.但是没能研究出来. 我就开始在网络上找关于使用python来抓取当天汇率的案例分 ...

  6. 用Python获取Linux资源信息的三种方法

    方法一:psutil模块 #!usr/bin/env python # -*- coding: utf-8 -*- import socket import psutil class NodeReso ...

  7. python 获取探针页面,自动查询公司出口

    在一些渗透当中,我们需要批量探针出口来达到我们的目的. 所以就有了这个丑陋简洁的小脚本. #!/usr/bin/env python #-*- coding:utf- -*- import sys i ...

  8. Python 获取本地主机信息

    import wmi c = wmi.WMI() for sys in c.Win32_OperatingSystem(): #系统信息 print(sys.Caption) #系统版本号 print ...

  9. python获取群成员信息

    #coding: utf-8 import itchat,datetime from itchat.content import TEXT itchat.auto_login(hotReload=Tr ...

随机推荐

  1. 【良心noip膜你赛】总结

    一点都不良心!!!! AK 快乐爆零快乐!!! 1. A. value512mb 1s规定一个区间的价值为这个区间中所有数 and 起来的值与这个区间所有数 or 起来的值的乘积.例如 3 个数 2, ...

  2. 【BZOJ 1010】 [HNOI2008]玩具装箱toy (斜率优化)

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9330  Solved: 3739 Descriptio ...

  3. 教程:使用 MongoDB、WCF、OData 和 PowerBI 构建 Azure 上的商业智能解决方案

     发布于 2014-05-20 作者 陈 忠岳 目录 概述 前提条件 创建 Windows Server 2012 Datacenter 虚拟机 通过 WCF(Windows Communicat ...

  4. 创建用于自定义SharePoint解决方案部署的Visual Studio项目

    转:http://soft.zdnet.com.cn/software_zone/2007/0903/488083.shtml 在基于SharePoint的开发中,我们通常会在WSS的TEMPLATE ...

  5. Firebug控制台详解

    转自:http://www.ruanyifeng.com/blog/2011/03/firebug_console_tutorial.html 作者: 阮一峰 日期: 2011年3月26日 Fireb ...

  6. Good Numbers

    Problem Description If we sum up every digit of a number and the result can be exactly divided by 10 ...

  7. Asp.net MVC Razor Generator

    Razor Generator开源工具使用简介: “Razor Generator” 前生“Razor Single File Generator for MVC” 这可以将MVC视图文件[.csht ...

  8. HW4.14

    public class Solution { public static void main(String[] args) { int count = 0; char asciiChar; for( ...

  9. opencv Installation in Linux and hello world

    http://opencv.org/quickstart.html Installation in Linux These steps have been tested for Ubuntu 10.0 ...

  10. 缓存算法–LRU

    LRU LRU是Least Recently Used 的缩写,翻译过来就是“最近最少使用”,也就是说,LRU缓存把最近最少使用的数据移除,让给最新读取的数据.而往往最常读取的,也是读取次数最多的,所 ...