Created
September 3, 2010 18:58
-
-
Save slashk/564369 to your computer and use it in GitHub Desktop.
fetches your daily and monthly adsense totals and sends them to your iphone via Prowl
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 | |
# created by admin AT mtbcalendar D0T com on 09-02-2010. | |
#### CUSTOMIZE THE VARIABLES BELOW | |
ADSENSE_LOGIN = "ENTER YOUR ADSENSE EMAIL LOGIN HERE" | |
ADSENSE_PASS = "ENTER YOUR ADSENSE PASSWORD HERE" | |
PROWL_API_KEY = "ENTER YOUR PROWL API HERE" | |
### DON'T CHANGE ANYTHING BELOW HERE | |
# install these gems with: | |
# $ gem install mechanize prowly | |
# see http://nokogiri.org/tutorials/installing_nokogiri.html if you issues installing mechanize | |
require 'rubygems' | |
require 'mechanize' | |
require 'prowly' | |
SERVICE_LOGIN_BOX_URL = "https://www.google.com/accounts/ServiceLoginBox?service=adsense<mpl=login&ifr=true&rm=hide&fpui=3&nui=15&alwf=true&passive=true&continue=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&hl=en_US" | |
TODAY_URL = "https://www.google.com/adsense/report/overview?timePeriod=today" | |
MONTH_URL = "https://www.google.com/adsense/report/overview?timePeriod=thismonth" | |
# go get google adsense login page | |
agent = Mechanize.new | |
page = agent.get SERVICE_LOGIN_BOX_URL | |
# fill in login page form with your credentials | |
form = page.forms.first | |
form.Email = ADSENSE_LOGIN | |
form.Passwd = ADSENSE_PASS | |
# submit login page, then click through the next page to get to account summary | |
page = agent.submit form | |
# parse account summary page today's for booty | |
page = agent.get TODAY_URL | |
todays_booty = page.search("//table[@id='summarytable']//tfoot//td/text()").last | |
# parse account summary page for this month's booty | |
page = agent.get MONTH_URL | |
months_booty = page.search("//table[@id='summarytable']//tfoot//td/text()").last | |
# send prowl notification to iphone (log to screen if fails) | |
notif = Prowly::Notification.new( | |
:apikey => PROWL_API_KEY, | |
:application => "Google AdSense", | |
:event => "Info", | |
:priority => Prowly::Notification::Priority::MODERATE, | |
:description => "Today's haul is #{todays_booty}\nMonthly haul is #{months_booty}") | |
response = Prowly.notify(notif) | |
puts response.message if response.status == "error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment