Skip to content

Instantly share code, notes, and snippets.

@masui
Created November 3, 2014 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masui/7a6713831d9ee9808b96 to your computer and use it in GitHub Desktop.
Save masui/7a6713831d9ee9808b96 to your computer and use it in GitHub Desktop.
GyazoりつつWebページを推薦するスクリプト
# -*- 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}'"
@masui
Copy link
Author

masui commented Nov 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment