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