Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

masui commented Nov 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.