Giter Club home page Giter Club logo

weibospider_sentimentanalysis's Introduction

微博用户的行为与情感分析

借助Python抓取微博数据,并对抓取的数据进行情绪分析

第一部分:微博数据抓取

参考自https://github.com/nghuyong/WeiboSpider/tree/search

(一)利用高级搜索抓取指定微博

本部分请参考文件夹WeiboSpider中的内容

1.安装依赖:

mongodb
phantomjs
redis
requirements.txt
(安装好mongodb之后需要新建数据库sina

2.构建账号池

购买微博小号,购买链接http://www.xiaohao.shop/
将账号密码复制到 WeiboSpider/sina/account_build/account.txt\ 运行 WeiboSpider/sina/account_build/login.py 运行成功会显示cookie创建成功

3.自定义检索条件

修改 WeiboSpider/sina/redis_init.py 中的日期,关键词,运行该文件进行微博检索
(本项目默认抓取热门微博,如需更改可将url中的sort设置为time)

4.开始爬虫

运行 WeiboSpider/sina/spider/weibo_spider.py 抓取目标数据
建议采取多线程同时抓取,提高速度
Mac用户在命令行中输入 scrapy crawl weibo_spider
Windows用户在命令行中输入 scrapy runspider weibo_spider.py multi 5.检查抓取的数据

数据会存储在sina database中,collection下会有tweets(微博)comments(评论)account(账号) tweets comments

(二)根据用户id抓取任意微博

本部分请参考文件夹WeiboSpiderSimple中的内容

1.安装依赖:

mongodb
requirements.txt\

2.替换cookie:

访问 https://weibo.cn/ 并登陆,获取对应的cookie,将WeiboSpiderSimple/sina/settings.py中的cookie换成你自己获取到的cookie

3.指定爬取的用户ID

WeiboSpiderSimple/sina/spider/weibo_spider.py中的start_uids换成你想抓取的对象的微博ID。

4.开始爬虫

执行scrapy crawl weibo_spider或者直接在pycharm当中运行WeiboSpiderSimple/sina/spider/weibo_spider.py

第二部分:探索性分析

EDA.py

第三部分:评论情绪分析

Sentiment analysis.ipynb

weibospider_sentimentanalysis's People

Contributors

piiven avatar seaweiqing avatar yanx27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weibospider_sentimentanalysis's Issues

Redis使用

用了10个账号,并发设置为1,延迟设置为1。现在爬不下来东西,是哪里出问题了吗?
image

请问最后爬不到数据是什么原因呢

2020-07-18 19:03:56 [scrapy.middleware] INFO: Enabled item pipelines:
['sina.pipelines.MongoDBPipeline']
2020-07-18 19:03:56 [scrapy.core.engine] INFO: Spider opened
2020-07-18 19:03:56 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2020-07-18 19:03:56 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2020-07-18 19:03:56 [py.warnings] WARNING: D:\study\Python3.7\lib\site-packages\scrapy\spiders_init_.py:81: UserWarning: Spider.make_requests_from_url method is deprecated: it will be removed and not be called by the default Spider.start_requests method in future Scrapy releases. Please override Spider.start_requests method instead.
warnings.warn(

限定微博地点和抓取用户个人信息

image
1.请问这段抓取个人信息的代码不能用吗?
2.配置好环境以后直接在redis_init.py中填写需要的关键词和时间段就可以运行了吗?如果想限定发微博的地点,能否直接在url_format中加一个“region=custom:xx:xx”呢?
3.如果查找的关键词有很多,在数据库中如何区分呢?能否增加一列字段为keyword?
4.还要就是爬的过程中出现error:list index out of range是什么情况呢

抓取数据显示

你好,我使用simple版本查看了一下我抓取的微博数据,Tweets和Comments对不上,比如说固定某一个Tweets,他对应的评论正常有23条,但是抓取的Comments显示只抓取了10条,并且这10条并不是连续的10条,好像随她喜欢,喜欢哪条评论抓哪条,这是什么原因?你们遇到过这种问题么?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.