Code Monkey home page Code Monkey logo

twitter-mining's Introduction

Świetna biblioteka do Twitter API: Twython - https://twython.readthedocs.org/en/latest/index.html Opis użycia Streaming API w Twythonie: https://twython.readthedocs.org/en/latest/usage/streaming_api.html

Instalacja Twythona:

$ sudo apt-get install pip
$ sudo pip install twython

Mongoengine:

$ sudo apt-get install python-mongoengine

###Wyświetlanie tweetów

#####Potrzebujemy:

Możemy je odpalać prosto z katalogów, które wypakujemy.

Załóżmy, że chcemy wyświetlać tweety, które znajdują się w bazie lokalnej 'twitter' i kolekcji 'generic_tweet'.

#####Konfiguracja Mongo:

  1. Odpalalamy mongo jako replikę

     $ sudo ./mongod --replSet "rs0"
    
  2. Łączymy się z bazą

     $ ./mongo
    
  3. Potem w terminalu

     $ use twitter
     $ rs.initiate()
    

#####Konfiguracja Elasticsearch:

  1. Bedąc w głównym katalogu pobieramy potrzebne wtyczki:

     $ ./bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.9.0
     $ ./bin/plugin --install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.0
     $ ./bin/plugin --url https://github.com/triforkams/geohash-facet/releases/download/geohash-facet-0.0.14/geohash-facet-0.0.14.jar --install geohash-facet
    
  2. Uruchamiamy Elasticsearch

     $ ./bin/elasticsearch
    
  3. Teraz konfiguracja:

     $ curl -XPUT 'localhost:9200/twitter' -d '{
         "mappings": {
           "generic_tweet" : {
             "properties" : {
               "_cls" : {
                 "type" : "string"
               },
               "_types" : {
                 "type" : "string"
               },
               "description" : {
                 "type" : "string"
               },
               "geo" : {
                 "type" : "double"
               },
               "geohash" : {
                 "type" : "string"
               },
               "location" : {
                 "type" : "geo_point"
               },
               "text" : {
                 "type" : "string"
               },
               "tweetid" : {
                 "type" : "long"
               },
               "userid" : {
                 "type" : "long"
               }
             }
           }
         }
       }'
     $ curl -XPUT 'localhost:9200/_river/twitter/_meta' -d '{ 
         "type": "mongodb", 
         "mongodb": { 
             "db": "twitter", 
             "collection": "generic_tweet"
         }, 
         "index": {
             "name": "twitter", 
             "type": "generic_tweet" 
         }
     }'
    
  4. Po wykonaniu powyższych komend utworzyliśmy indeks o nazwie 'twitter' z elementami o typie 'generic_tweet', które pobieramy z lokalnej bazy 'twitter' i kolekcji 'generic_tweet'.

  5. Restatrujemy Elasticrearch. Aby sprawdzić czy wszystko działa wpisujemy w przegladarke:

     $ http://localhost:9200/twitter/_search?search_type=count&pretty=1
    
  6. Jeśli otrzymaliśmy JSONa z odpowiedzią, gdzie klucz "total" jest rózny od zera to prawdopodobnie wszystko jest ok.

twitter-mining's People

Contributors

blostic avatar dextero avatar michalpawlicki avatar radk0s avatar ribaldrhino avatar

Watchers

 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.