Giter Site home page Giter Site logo

twitter-past-crawler's Introduction

twitter-past-crawler

Description

The official twitter API as of now is very limiting in the access it provides to past tweets. This crawler attempts to provide users the ability to collect past tweets beyond those limitations. This is done by emulating the infinite scroll on the search page.

Requirements

The following packages are required:

  • requests
  • Beautiful Soap 4

Installation

$ pip install twitterpastcrawler

Usage

See samples/ for more examples. Below is an example of how to use this crawler:

import twitterpastcrawler

crawler = twitterpastcrawler.TwitterCrawler(
							query="#haiku", # searches for tweets that respond to the query, "#haiku"
							output_file="haiku.csv" # outputs results to haiku.csv
						)

crawler.crawl() # commences the crawl

The following attributes can be specified upon initialization:

  • query(str): The search query to run. The query should be formed according to the Twitter Search API.
  • max_depth(int): The maximum number of times this crawler will send requests to twitter.
  • parser(generator): A generator that takes a crawler and the entire inner HTML of the tweet stream from the response as input and yields a bs4.element.Tag object for each tweet.
  • tweet_parser(function): A function that takes a crawler and bs4.element.Tag object for a single tweet as input and outputs a twittercrawler.Tweet object.
  • handler(function): A function that takes a crawler and twittercrawler.Tweet object as input and performs some functionality using it. The default handler outputs the details of the tweet to a csv file.
  • init_min_pos(str): The position to start crawling at within the infinite stream of tweets.
  • output_file(str): The file to output the results of the crawl to, in the case that the user uses the default handler.
  • parameters(list): The parameters that will be output to the csv file in the case that the user uses the default handler.

See the following link for information regarding the search API of twitter: https://dev.twitter.com/rest/public/search

License

Copyright (c) 2017 by Keita Kurita Released under the MIT license https://opensource.org/licenses/mit-license.php

twitter-past-crawler's People

Contributors

kristopheryahoo avatar keitakurita avatar joaocarabetta avatar

Watchers

James Cloos avatar  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.