我的第一个网页爬虫(python)
来源:互联网 发布:易语言dnf辅助源码模板 编辑:程序博客网 时间:2024/05/29 13:06
1、环境:python 3.5.1 编辑器:pycharm
2、学习网站:http://python.jobbole.com/81336/
3、实战:
使用该页面中提到的语句,python 3.5.1报错,无法识别urllib2的库,如:
解决办法:原来urllib2和urllib库已经合并变成urllib库,提醒:不同的python版本可能库不一样,需要关注库的变化情况
脚本优化(参考地址:http://www.imooc.com/article/15230):
from urllib import requestresponse = request.urlopen("http://www.baidu.com")print(response.read().decode("utf-8"))
运行结果(简化版):
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta content="always" name="referrer">
<meta name="theme-color" content="#2932e1">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" href="/content-search.xml" title="百度搜索" />
<link rel="icon" sizes="any" mask href="//www.baidu.com/img/baidu.svg">
<link rel="dns-prefetch" href="//s1.bdstatic.com"/>
<link rel="dns-prefetch" href="//t1.baidu.com"/>
<link rel="dns-prefetch" href="//t2.baidu.com"/>
<link rel="dns-prefetch" href="//t3.baidu.com"/>
<link rel="dns-prefetch" href="//t10.baidu.com"/>
<link rel="dns-prefetch" href="//t11.baidu.com"/>
<link rel="dns-prefetch" href="//t12.baidu.com"/>
<link rel="dns-prefetch" href="//b1.bdstatic.com"/>
<title>百度一下,你就知道</title>
<style id="css_index" index="index" type="text/css">html,body{height:100%}
html{overflow-y:auto}
body{font:12px arial;text-align:;background:#fff}
body,p,form,ul,li{margin:0;padding:0;list-style:none}
body,form,#fm{position:relative}
td{text-align:left}
img{border:0}
- 我的第一个网页爬虫(python)
- 我的第一个Python爬虫
- 我的第一个python爬虫脚本
- 关于我的第一个爬虫--Python+selenium+parsel+动态网页
- 我的第一个爬虫
- 我的第一个爬虫
- 我写的第一个用Python写的爬虫
- 纪念我的第一个Python爬虫——图片
- 我的第一个小爬虫程序-python
- 我的第一个网页
- 我的第一个网页
- Python爬虫学习:我的第一个爬虫—爬取贴吧感兴趣帖子的图片(大家都懂,哈哈)
- 我的第一个小爬虫
- 我的第一个爬虫日志
- 我的第一个爬虫程序
- 我的第一个豆瓣短评爬虫
- 我写的第一个图片爬虫
- python第一个爬虫
- ThinkPHP 图片上传 改路径上传
- Dev 配置checkedListBoxControl值
- oj 序列判断
- 【LeetCode】 Binary Search 二分搜索
- CSS(二)— 样式加载
- 我的第一个网页爬虫(python)
- 解析enable_shared_from_this
- VPS搭建SS
- Android——蓝牙传输
- 欢迎使用CSDN-markdown编辑器
- python3 爬取妹子图。。。
- Proc 文件系统实现原理
- VS 搜索内容失败怎么办
- 框架知识点