Scraper for Twitter embedded timelines.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


JavaScript scraper for Twitter embedded timelines.

When you copy and paste the code you get from Twitter, you have to replace this:

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+"://";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

... with this, in order to have an onTimelineRender event:

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+"://";js.setAttribute('onload', "'rendered',function(e) {Timeline.onLoad(e)});");fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

In order to get the the serialized object, you need to call Timeline.serialize, and pass the iframe created by the embedded timeline as a parameter to that function. If you don't want to deal with that, adding an event to listen for onTimelineRender should work better for you:

document.addEventListener('onTimelineRender', function(e) {
	var data = Timeline.serialize(e.detail.timeline);

You can see the example.html file to see how it is used.

Example output is in this format:

    "id": "439123783694028800",
    "user": {
        "name": "Alex Sexton",
        "username": "SlexAxton",
        "avatar": {
            "x1": "",
            "x2": ""
    "text": "JavaScript: The Good Farts.\n\n(I've been holding on to this tweet for 22 months)",
    "time": "2014-02-27T19:44:03.000Z",
    "url": "",
    "stats": {
        "rt": 51,
        "fav": 46
    "retweeted": true,
    "photo": false,
    "playable": false