Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各メディアの情報を収集して整理・配信したい #26

Open
kkd opened this issue Jul 18, 2018 · 2 comments
Open

各メディアの情報を収集して整理・配信したい #26

kkd opened this issue Jul 18, 2018 · 2 comments
Labels
ボランティア向け ボランティア希望者にとって役立つ内容 後方支援者向け 被災地に行けないが後方支援したい人に役立つもの 機能改善 New feature or request 自動化 データの自動取得、記事の自動修正など。人力を使わずできるようにしたい。

Comments

@kkd
Copy link
Contributor

kkd commented Jul 18, 2018

ここに一覧がある。

@kkd
Copy link
Contributor Author

kkd commented Jul 18, 2018

まずはRSS化からかな?

@kkd kkd added 機能改善 New feature or request 自動化 データの自動取得、記事の自動修正など。人力を使わずできるようにしたい。 ボランティア向け ボランティア希望者にとって役立つ内容 後方支援者向け 被災地に行けないが後方支援したい人に役立つもの labels Jul 25, 2018
@imabari
Copy link
Contributor

imabari commented Aug 10, 2018

愛媛新聞とNHK松山のTwitterの投稿をRT
他のところはほとんど記事ないので

import twitter
import datetime
from pytz import timezone

api = twitter.Api(
    consumer_key='',
    consumer_secret='',
    access_token_key='',
    access_token_secret='')

user_lists = ['ehime_np', 'nhk_matsuyama']

text_lists = ['愛媛豪雨災害', '西日本豪雨']

# タイムゾーン取得

for user_id in user_lists:

    tweets = api.GetUserTimeline(screen_name=user_id)

    for tweet in tweets:

        # 投稿日時
        dt_date = datetime.datetime.strptime(
            tweet.created_at, '%a %b %d %H:%M:%S %z %Y').astimezone(
                timezone('Asia/Tokyo'))

        # 一時間前
        dt_now = datetime.datetime.now(
            timezone('Asia/Tokyo')) - datetime.timedelta(hours=1)

        if dt_date > dt_now:

            # ツイート分の中にリストの文字があるか
            for i in text_lists:
                if i in tweet.text:

                    # リツイート済みか
                    if not tweet.retweeted:

                        # リツイート
                        api.PostRetweet(tweet.id)

                        print(tweet.text)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ボランティア向け ボランティア希望者にとって役立つ内容 後方支援者向け 被災地に行けないが後方支援したい人に役立つもの 機能改善 New feature or request 自動化 データの自動取得、記事の自動修正など。人力を使わずできるようにしたい。
Projects
None yet
Development

No branches or pull requests

2 participants