Last active
December 19, 2016 15:03
-
-
Save oboenikui/aeab91bfb5ab5d198a30 to your computer and use it in GitHub Desktop.
tarusho
This file contains hidden or 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
require 'rubygems' | |
require 'twitter' | |
require 'net/http' | |
require 'uri' | |
require 'nokogiri' | |
CONSUMER_KEY = "replace to your api key" | |
CONSUMER_SECRET = "replace to your api secret" | |
ACCESS_TOKEN = "replace to your access token" | |
ACCESS_TOKEN_SECRET = "replace to your access token secret" | |
def shindan(id) | |
url = 'https://shindanmaker.com/' << id | |
uri = URI.parse(url) | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
req = Net::HTTP::Post.new(uri.request_uri) | |
data = "u=oboenikui" | |
req.body = data | |
res = https.request(req) | |
document = Nokogiri::HTML.parse(res.body, nil, "UTF-8") | |
document.css("#copy_text_140").children[0].text | |
end | |
def post_shindan(id) | |
twitter_client = Twitter::REST::Client.new do |config| | |
config.consumer_key = CONSUMER_KEY | |
config.consumer_secret = CONSUMER_SECRET | |
config.access_token = ACCESS_TOKEN | |
config.access_token_secret = ACCESS_TOKEN_SECRET | |
end | |
twitter_client.update(shindan(id)) | |
end | |
post_shindan("456799") | |
post_shindan("495678") | |
post_shindan("453170") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment