Created
January 30, 2012 01:24
-
-
Save neonichu/1701800 to your computer and use it in GitHub Desktop.
Automatically post to your Google+ account from the commandline.
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
#!/usr/bin/env ruby | |
##### Automatically post to your Google+ account from the commandline. | |
##### (C) 2012 Boris Buegling <boris@icculus.org> | |
require 'rubygems' | |
require 'mechanize' | |
## Use Windows Mobile user agent to get Basic Mobile HTML | |
agent = Mechanize.new | |
agent.user_agent = 'HTC_Mega Opera/9.5 (Microsoft Windows; PPC Opera Mobi /17753; U; es-ES)' | |
## Login to Google account | |
page = agent.get('https://accounts.google.com/ServiceLoginAuth') | |
form = page.forms.first | |
form.Email = '<<<username>>>' | |
form.Passwd = '<<<password>>>' | |
agent.submit form | |
## Click on 'Post' | |
page = agent.get('https://plus.google.com') | |
post = page.links_with(:text => 'Post').first | |
## Write the post | |
page = agent.click post | |
form = page.forms.first | |
form.newcontent = '<<<text to post>>>' | |
post = form.button_with(:value => 'Post') | |
form.submit post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment