Gplus script version 1.1


In previous post, when I run gplus script it will display

the stream from circle we mentioned in command

eg. ruby gplus.rb username password circle_name

In this version , It will prompt for username and password .. and it displays all circle names of

current user .. and we can see streams of any circle shown 🙂

 

Dependencies:

ruby, rubygems, mechanize(gem),  highline (gem for secure password)

Ruby code

=begin
Program name: Gplus script
Date Written: 16/08/2011
Date Modified: 17/08/2011
Author : Sathianarayanan.S
License: GPL2.0
Version: 1.1
=end
begin
require 'rubygems'
require 'mechanize'
require "highline/import"

print "Enter your username: "
username = gets.chomp
password = ask("Enter the password :" ) { |p| p.echo = "*" }
password = password.chomp

agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get("https://www.google.com/accounts/ServiceLogin?service=oz&continue=https://plus.google.com/?gpcaz%3D94cd3e2c&ltmpl=es2st&hideNewAccountLink=1&hl=en-GB")
puts 'Logggig....'
puts "=========================================================================\n"
form = page.forms.first
form.Email = username
form.Passwd = password

page = agent.submit form
circles = agent.page.search('#content .c-j.a-nb-j.a-nb-Jh-j')

puts 'Streams:'
i = 1
circles.each do |circle|
  puts i.to_s+') '+circle
  i+=1
end
puts "=========================================================================\n"
while true
 print "Enter circle: "
 circle_name = gets.chomp

 page = agent.page.link_with(:text => circle_name).click

 streams = page.search('#contentPane div.sj')
 i = 1
 streams.each do |stream|
   if stream.text != ''
     puts i.to_s+') '+stream.search('span.kh').text+' shared:'
     puts stream.search('div.eo').text
   else
     puts  i.to_s+') '+'Video/photos...'
   end
   puts ''
   i+=1
 end
 puts "=========================================================================\n"
end

rescue SocketError
 puts 'Error in internet connection'
rescue NoMethodError
  puts 'Invalid username or password or circle'
rescue Interrupt
  puts "\n========================================================================="
  puts "\nQuiting...."
end
Advertisements

About sathia

Web developer at cloudmint
This entry was posted in programs and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

3 Responses to Gplus script version 1.1

  1. Angelique says:

    Pretty insightful. Thanks!

    My blog:
    DSL Anbieter dslvergleichdsl.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s