This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#画像URLリストを作成 | |
urls = [] | |
#添付ファイルが動画の場合が動画URLを取得 | |
if 'video_info' in tweet['extended_entities']['media'][0]: | |
urls.append(tweet['extended_entities']['media'][0]['video_info']['variants'][-1]['url']) | |
#添付ファイルが画像の場合は最大4つの画像URLを取得 | |
else: | |
for media in tweet['extended_entities']['media']: | |
urls.append(media['media_url']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#必要な要素を取得 | |
user_id = tweet['user']['id_str'] | |
text = tweet['text'] | |
url_id = text.split('/')[-1] | |
d = re.search(digit6, text).group() | |
date = '20' + '-'.join([d[:4], d[4:6], d[6:]]) | |
#ディレクトリ設定 | |
dir = user_id + '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"user": { | |
"follow_request_sent": false, | |
"has_extended_profile": false, | |
"profile_use_background_image": true, | |
"default_profile_image": false, | |
"id": 977837449182244865, | |
"profile_background_image_url_https": null, | |
"verified": false, | |
"translator_type": "none", | |
"profile_text_color": "333333", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
#1件目のツイート | |
{ | |
#RT元の情報。RTでないためnull | |
"contributors": null, | |
"truncated": false, | |
#ツイート本文(エスケープされたunicode)。ここでは「テストのツイート」と書いてある | |
"text": "\u30c6\u30b9\u30c8\u306e\u30c4\u30a4\u30fc\u30c8", | |
"is_quote_status": false, | |
"in_reply_to_status_id": null, |