Giter Club home page Giter Club logo

actor-twitter-scraper's Introduction

Tweet Scraper

The actor crawls specified twitter profiles and scrapes the following information:

  • Name
  • Description
  • Location
  • Date joined
  • List of tweets, retweets, and replies
  • Number of favorites, replies, and retweets for each tweet
  • Conversation threads the tweets belong to

The actor is useful for extracting large amounts of tweet data. Unlike the Twitter API, it does not have rate limit contraints.

Input Configuration

The actor has the following input options

  • Login Cookies - Your Twitter login cookies (no username/password is submitted). For instructions on how to get your login cookies, please see our tutorial.
  • List of Handles - Specify a list of twitter handles (usernames) you want to scrape shall the crawler visit. If zero, the actor ignores the links and only crawls the Start URLs.
  • Max. Tweets - Specify the maximum number of tweets you want to scrape.
  • Proxy Configuration - Optionally, select a proxy to be used by the actor.

Results

The actor stores its results into the default dataset associated with the actor run, from where they can be downloaded in formats like JSON, HTML, CSV or Excel.

For each Twitter profile scraped, the resulting dataset contains a single record, which looks as follows (in JSON format):

{
  "user": {
    "name": "Patrick Collison",
    "description": "Fallibilist, optimist. Stripe CEO.",
    "location": "[email protected]",
    "joined": "Tue Apr 17 01:46:27 +0000 2007",
    "username": "patrickc"
  },
  "tweets": [
    {
      "contentText": "@balajis I'm very happy to visit many restaurants that I suspect are not particularly good businesses.",
      "conversationId": "1162066623240347648",
      "replies": 2,
      "retweets": 0,
      "favorites": 51,
      "dateTime": "Thu Aug 15 18:23:53 +0000 2019",
      "tweetId": "1162067401954869248"
    },
    {
      "contentText": "I've wanted this feature for so long. ๐Ÿ˜ https://t.co/jspRvv8wDD https://t.co/Q0gRwwIGYd https://t.co/k30UK0hvdc",
      "conversationId": "1161319133570457600",
      "replies": 13,
      "retweets": 12,
      "favorites": 247,
      "dateTime": "Tue Aug 13 16:50:32 +0000 2019",
      "tweetId": "1161319133570457600"
    },
    ... 
  ]
}

To download the results, you can use the Get items Apify API endpoint.

https://api.apify.com/v2/datasets/[DATASET_ID]/items?format=json

Where DATASET_ID is the ID of the dataset as provided in the actor run object. You can use the format query parameter to specify format of the results, e.g. xml, csv or xlsx.

actor-twitter-scraper's People

Contributors

jancurn avatar michalblaha avatar

Stargazers

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

Watchers

 avatar  avatar

actor-twitter-scraper's Issues

Crashes after reach thousands of tweets.

It is likely that the browser itself runs out of memory.

(node:8) UnhandledPromiseRejectionWarning: Error: Page crashed!

The solution should be running with more memory. But we nee a better error.

Stability issues

Over the last week or two several users reported the problems with the actor:

When I send anything over a couple of handles to crawl, the error rates are very high. What would be the recommendation to make this better?

We are actively using this scraper with only about 10% success rates

Another user is trying to scrape data from up to 5 years old - fails with Navigation timeout.

Seems like It's still working with SDK 0.14.5, so maybe it just requires some refresh/update everything to latest, etc.

Follow threads

Get all messages from other users from an specific thread

Puppeteer Crawler: handleRequest Function failed, reclaiming failed request back to the list or queue

The twitter-scraper is not working anymore. Would you please help me with this?
Here's the log:

2021-10-21T18:34:10.678Z ACTOR: Pulling Docker image from repository.
2021-10-21T18:34:10.767Z ACTOR: Creating Docker container.
2021-10-21T18:34:11.132Z ACTOR: Starting Docker container.
2021-10-21T18:34:13.604Z INFO System info {"apifyVersion":"2.0.7","apifyClientVersion":"1.4.2","osType":"Linux","nodeVersion":"v16.8.0"}
2021-10-21T18:34:14.712Z INFO Limiting tweet counts to 1000...
2021-10-21T18:34:17.785Z INFO Starting scraper
2021-10-21T18:34:17.827Z INFO PuppeteerCrawler:AutoscaledPool: state {"currentConcurrency":0,"desiredConcurrency":1,"systemStatus":{"isSystemIdle":true,"memInfo":{"isOverloaded":false,"limitRatio":0.2,"actualRatio":null},"eventLoopInfo":{"isOverloaded":false,"limitRatio":0.6,"actualRatio":null},"cpuInfo":{"isOverloaded":false,"limitRatio":0.4,"actualRatio":null},"clientInfo":{"isOverloaded":false,"limitRatio":0.3,"actualRatio":null}}}
2021-10-21T18:34:24.958Z INFO Finished with https://twitter.com/nikestore
2021-10-21T18:34:24.961Z INFO Extracted 16 tweets from https://twitter.com/nikestore
2021-10-21T18:34:24.962Z ERROR PuppeteerCrawler: handleRequestFunction failed, reclaiming failed request back to the list or queue {"url":"https://twitter.com/nikestore","retryCount":1,"id":"YcyP6dQ98FjF5k0"}
2021-10-21T18:34:24.962Z SyntaxError: Unexpected token ) in JSON at position 0
2021-10-21T18:34:24.963Z at JSON.parse ()
2021-10-21T18:34:24.964Z at HTTPResponse.json (/home/myuser/node_modules/puppeteer/lib/cjs/puppeteer/common/HTTPResponse.js:125:21)
2021-10-21T18:34:24.964Z at runMicrotasks ()
2021-10-21T18:34:24.965Z at processTicksAndRejections (node:internal/process/task_queues:96:5)
2021-10-21T18:34:24.965Z at async /home/myuser/src/main.js:309:35
2021-10-21T18:34:36.889Z INFO Finished with https://twitter.com/nikestore
2021-10-21T18:34:36.890Z ERROR PuppeteerCrawler: handleRequestFunction failed, reclaiming failed request back to the list or queue {"url":"https://twitter.com/nikestore","retryCount":2,"id":"YcyP6dQ98FjF5k0"}
2021-10-21T18:34:36.891Z SyntaxError: Unexpected token ) in JSON at position 0
2021-10-21T18:34:36.891Z at JSON.parse ()
2021-10-21T18:34:36.892Z at HTTPResponse.json (/home/myuser/node_modules/puppeteer/lib/cjs/puppeteer/common/HTTPResponse.js:125:21)
2021-10-21T18:34:36.892Z at runMicrotasks ()
2021-10-21T18:34:36.892Z at processTicksAndRejections (node:internal/process/task_queues:96:5)
2021-10-21T18:34:36.893Z at async /home/myuser/src/main.js:309:35
2021-10-21T18:34:43.268Z INFO Finished with https://twitter.com/nikestore
2021-10-21T18:34:43.269Z ERROR PuppeteerCrawler: handleRequestFunction failed, reclaiming failed request back to the list or queue {"url":"https://twitter.com/nikestore","retryCount":3,"id":"YcyP6dQ98FjF5k0"}
2021-10-21T18:34:43.269Z SyntaxError: Unexpected token ) in JSON at position 0
2021-10-21T18:34:43.270Z at JSON.parse ()
2021-10-21T18:34:43.270Z at HTTPResponse.json (/home/myuser/node_modules/puppeteer/lib/cjs/puppeteer/common/HTTPResponse.js:125:21)
2021-10-21T18:34:43.270Z at runMicrotasks ()
2021-10-21T18:34:43.271Z at processTicksAndRejections (node:internal/process/task_queues:96:5)
2021-10-21T18:34:43.273Z at async /home/myuser/src/main.js:309:35
2021-10-21T18:34:52.849Z INFO Finished with https://twitter.com/nikestore
2021-10-21T18:34:52.963Z ERROR https://twitter.com/nikestore failed 3 times and won't be retried anymore...
2021-10-21T18:34:53.052Z INFO PuppeteerCrawler: All the requests from request list and/or request queue have been processed, the crawler will shut down.
2021-10-21T18:34:53.381Z INFO PuppeteerCrawler: Final request statistics: {"requestsFinished":0,"requestsFailed":1,"retryHistogram":[null,null,null,1],"requestAvgFailedDurationMillis":5916,"requestAvgFinishedDurationMillis":null,"requestsFinishedPerMinute":0,"requestsFailedPerMinute":1,"requestTotalDurationMillis":5916,"requestsTotal":1,"crawlerRuntimeMillis":35598}
2021-10-21T18:34:53.382Z INFO All finished
2021-10-21T18:34:53.531Z

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.