Skip to content

Instantly share code, notes, and snippets.

@shibafu528
Created July 4, 2015 13:04
Show Gist options
  • Save shibafu528/010d752118c4d119f3d0 to your computer and use it in GitHub Desktop.
Save shibafu528/010d752118c4d119f3d0 to your computer and use it in GitHub Desktop.
# coding: utf-8
require 'mechanize'
require 'twitter'
# Twitter OAuth
CK = ""
CS = ""
AT = ""
ATS = ""
# 抽出ソース
SITES = ["http://owen.ga/chry545%E3%81%AE%E9%97%87%EF%BC%88%E6%94%B9%EF%BC%89",
"http://owen.ga/chry545%E3%81%AE%E9%97%87%E6%94%B9%E3%81%9D%E3%81%AE2"]
def get_tweet_urls(source_url)
agent = Mechanize.new
page = agent.get(source_url)
page.search('a[href^="https://twitter.com/chry545/status"]').map { |n| n['href'] }
end
tweets = SITES.map{|url| get_tweet_urls(url) }.flatten
client = Twitter::REST::Client.new do |config|
config.consumer_key = CK
config.consumer_secret = CS
config.access_token = AT
config.access_token_secret = ATS
end
client.retweet(tweets.sample)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment