Coder Social home page Coder Social logo

xty-self / weibospider_sentimentanalysis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cuhksz-tql/weibospider_sentimentanalysis

0.0 1.0 0.0 7.1 MB

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

Python 29.67% Jupyter Notebook 70.33%

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

seaweiqing avatar yanx27 avatar piiven avatar

Watchers

James Cloos avatar

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.