《python爬虫伊始(百度首页)》
来源:互联网 发布:信息技术网络研修心得 编辑:程序博客网 时间:2024/06/07 21:01
新手爬虫简单的几行代码就能实现
这里需要使用到requests库
在cmd中输入pip install requests 就能完成requests库的下载
下面开始简单的代码
#CrawWeb.pyimport requestsurl = "http://www.baidu.com"try: r = requests.get(url) r.raise_for_status() r.encoding = r.apparent_encoding print(r.text[:1000])except: print("error")
<!DOCTYPE html>
<!--STATUS OK--><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><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su va
以上是爬取的内容
阅读全文
0 0
- 《python爬虫伊始(百度首页)》
- python爬虫系列(一)百度首页爬取
- Python爬虫--捕捉网易首页
- python与matlab爬虫百度图片首页的图片(urllib.request)
- python爬虫(抓取百度新闻列表)
- python爬虫(抓取百度图片)
- Python爬虫百度照片
- python百度语法爬虫
- python爬虫百度翻译
- Python 百度爬虫图片
- Python爬虫实践(九):第一个爬虫实例(简书首页)
- Java爬虫历险记 -- (1)爬取百度首页的logo
- python之百度首页搜索设置的鼠标捕获功能代码(2017年新款百度首页)
- python百度贴吧爬虫
- python 爬虫百度搜索结果
- Python简易百度百科爬虫
- 百度图片爬虫-python语言
- python 百度贴吧爬虫
- mysql [Err] 1292
- 同步定位与地图构建SLAM过程
- Android--RadioGroup和Tablayout两种实现底部导航的方式详解
- PHP环境搭建(7)----fpm配置
- [BZOJ 3757]苹果树:树上莫队
- 《python爬虫伊始(百度首页)》
- 第十五章 单点登录——《跟我学Shiro》
- Java中面向对象特征之一封装
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- 第十六章 综合实例——《跟我学Shiro》
- 【Linux】Linux将命令添加到PATH中
- 学习java的心态要好!
- bzoj 3697 采药人的路径
- 洛谷 P1067 多项式输出(恶心纯模拟)