0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Twitter Webのダウンロード機能で取得したTwitterデータの利用方法

Posted at

本内容を利用した場合の一切の責任を私は負いません。

何故かググってもヒットしなかったので、念のために。

取得したアーカイブの中にtweet.jsファイルがあり、この中にTweetが入っている。
先頭はこんな感じで、JSONではなくJavascriptのコードという感じ。

tweet.js
window.YTD.tweet.part0 = [ {
  "retweeted" : false,
  "source" : "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
  "entities" : {
    "hashtags" : [ ],
    "symbols" : [ ],
    "user_mentions" : [ ],
    "urls" : [ ]
  },
  "display_text_range" : [ "0", "14" ],

} ]

ググったものはJSONに見立てるために文字処理でパース(?)している。
eval関数でそのまま使ってはダメなの???
window変数定義が嫌だから???

const fs = require("fs");
var window =
    {
        YTD:
            {
                tweet:
                    {
                        part0: [],
                        reserved: []
                    }
            }
    };
var dlTweet = fs.readFileSync("./tweet","utf-8");
eval(dlTweet);
var Tweet = window.YTD.tweet.part0;
console.log(Tweet.length);

自分で定義できるので、自分用のreservedプロパティを追加したりもできる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?