Created
November 3, 2014 04:37
-
-
Save masui/7a6713831d9ee9808b96 to your computer and use it in GitHub Desktop.
GyazoりつつWebページを推薦するスクリプト
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
# -*- coding: utf-8 -*- | |
require 'open-uri' | |
require 'nokogiri' | |
require 'httparty' | |
require 'net/http' | |
require 'uri' | |
# | |
# FirefoxをアクティブにしてURLを取得 | |
# | |
system "osascript -e ' | |
tell application \"Firefox\" to activate | |
delay 0.1 | |
tell application \"System Events\" to tell process \"Firefox\" | |
keystroke \"l\" using command down | |
keystroke \"c\" using command down | |
end tell'" | |
page_url = `pbpaste` | |
# | |
# Gyazoを起動してGyazoのURLを取得 | |
# | |
system "/Applications/Gyazo.app/Contents/MacOS/Gyazo" | |
gyazo_url = `pbpaste` | |
# | |
# ページのタイトルを取得 | |
# | |
page_title = Nokogiri::parse(HTTParty.get(page_url).body).xpath('//title').text | |
HTTParty.get URI.escape("http://gyazz.masuilab.org/__write?name=osusume&title=#{page_title}&data=[[#{page_url} #{gyazo_url}.png]]") | |
#url = URI.parse("http://gyazz.masuilab.org") | |
#res = Net::HTTP.start(url.host, url.port) {|http| | |
# http.get(URI.escape("/__write?name=osusume&title=#{page_title}&data=[[#{page_url} #{gyazo_url}.png]]")) | |
#} | |
system "open 'http://gyazz.masuilab.org/osusume/#{page_title}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://GitHub.com/masui/Gyup で開発続行