Python爬虫(2)——爬取微博内容
来源:互联网 发布:端口定义 编辑:程序博客网 时间:2024/06/05 12:44
本文通过一种简单的方式来抓取华为终端官方微博的内容信息。首先抓取登录微博的cookie,然后使用cookie来登录微博。
具体的代码如下所示:
# -*- coding: utf-8 -*-"""Created on Sun Apr 16 14:16:32 2017@author: zch"""import requestsfrom bs4 import BeautifulSoupimport timeimport pandas as pd#放入cookie信息cook = {"Cookie":"_T_WM=..."} #爬取华为终端官方微博的内容url = "https://weibo.cn/huaweidevice"html = requests.get(url,cookies=cook).content#使用Beautiful来解析网页内容。soup =BeautifulSoup(html,"html.parser")r = soup.findAll('span',attrs={"class" : "ctt"})for e in r: print(e.text)
运行结果如下所示:
当然,上面的代码一次只能实现爬取少量的内容信息,还很简陋。后面要想办法解决多页连续爬取和自动分类存储的问题。
0 0
- Python爬虫(2)——爬取微博内容
- python爬虫——获取正文内容
- Python 爬虫4——使用正则表达式筛选内容
- Python 爬虫 —— 获取js渲染的内容
- python爬虫(18)爬取微信公众号内容——绘制词云
- Python 网络爬虫与信息获取(二)—— 页面内容提取
- python爬虫(1):爬取糗百内容
- Python爬虫(一)——了解爬虫
- python——爬虫
- python——爬虫
- Python——爬虫
- python爬虫—安装
- Python爬虫实战(1)——百度贴吧抓取帖子并保存内容和图片
- python爬虫-->抓取动态内容
- Python 爬虫1——爬虫简述
- Python爬虫----爬虫入门(2)
- python——爬虫学习——基于bs4库的HTML内容查找方法-(3)
- Python 简易网络爬虫的编写——抓取任意页面数目百度百科内容
- self parent this 区别
- erlang 四大 behaviour【转】
- Unity3d实现人物跳跃
- Rmarkdown中文实现
- map容器的初体验
- Python爬虫(2)——爬取微博内容
- 《重构-改善既有代码的设计》读后感
- 配置Log4j(很详细)
- nyoj-街区最短路径问题
- Glide源码分析
- HMLT/CSS
- HDU4283 区间dp
- 待解决
- 我理解的webservice是这样的