import urllib.request
response = urllib.request.urlopen("http://www.baidu.com")
html = response.read()
html = html.decode('UTF-8')
print(html)

其中用 用urllib.request 中的urlopen打开百度(一定要加http,用read方法读取html代码,用 utf—8 解码。

其中,response对象有一个getcode()方法,可以得到HTTP状态码(200为成功

其中baidu能够正常访问,google访问超时,其中传入的三个参数:URL,向服务器发送的数据(没有为None,也可缺省),超时时间

返回的异常最后一句,timed out

最新文章

  1. 常用Web Service汇总(天气预报、时刻表等)
  2. 对ArrayList操作时报错java.util.ConcurrentModificationException null
  3. easyui combobox 值怎样获取
  4. C# 调用第三方DLL完整实例
  5. Error Domain=com.google.greenhouse Code=-102
  6. POJ 2029 DP || 暴力
  7. iOS 调试 之 打印
  8. 老李谈HTTP1.1的长连接 2
  9. web service 组件
  10. 常用的Linux发行版
  11. Android异步消息机制
  12. 在不重装系统的情况下创建Linux的Swap分区
  13. python基础15下_迭代器_生成器
  14. document.getElementsByClassName() 原生方法 通过className 选择DOM节点
  15. Introduce oneself
  16. POJ 2367:Genealogical tree(拓扑排序模板)
  17. 源码之Java集合
  18. 通过mysqltools全自动安装配置mysql复制环境
  19. jquery背景backgroundPosition插件
  20. HDU 2848 Number Cutting Game(博弈思想 + dfs)题解

热门文章

  1. Fragment的陷阱
  2. geopandas python地图绘制
  3. xib autolayout subview
  4. 《MVC +EasyUI 》——表单的提交
  5. vim 指令学习
  6. JVM Specification 9th Edition (2) Chapter 1. Introduction
  7. ecmall 中Url体系改造实践
  8. 使用WinSCP这个软件使linux和win7互传文件
  9. JS——覆盖显示,点击显示三层
  10. 小型web服务器thttpd的学习总结(下)