class AdtekioAdnetworks::ApiKeyScrapers
Attributes
agent[R]
params[R]
Public Class Methods
new()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 7 def initialize @agent = Mechanize.new @agent.user_agent_alias = 'Mac Mozilla' end
supporter_adnetworks()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 17 def self.supporter_adnetworks public_instance_methods. select { |a| a =~ /key_for_/ }.map { |a| a.to_s.sub(/key_for_/,'') } end
Public Instance Methods
key_for_adcolony()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/adcolony.rb, line 3 def key_for_adcolony return_token_hash do csrf_token = get_and_match("https://clients.adcolony.com/login", /_csrf.:.([^"]+)"/) data = { "_csrf" => csrf_token, "email" => params["username"], "password" => params["password"] } post_and_match("https://clients.adcolony.com/login", data, /single_access_token.:.([^"]+)"/) end end
key_for_applift()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/applift.rb, line 3 def key_for_applift return_token_hash do enter_login_details(_g("https://partner.applift.com").forms.first). submit get_and_match("https://partner.applift.com/stats/stats_api", /Your API Key .+ <i>([^ ]+)[<]/) end end
key_for_applovin()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/applovin.rb, line 3 def key_for_applovin return_token_hash do enter_login_details(_g("https://www.applovin.com/login").forms.first). submit page = _g("https://www.applovin.com/account") page.search("input[id=report_key]").first.attributes["value"].value end end
key_for_chartboost()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/chartboost.rb, line 3 def key_for_chartboost return_result_hash do |result| _p("https://dashapi.chartboost.com/v3/login", { "email" => params["username"], "password" => params["password"] }) chsh = JSON.parse(_g("https://dashapi.chartboost.com/v3/"+ "companies?with=money%2users,ounts").content) result["user_id"] = chsh["response"]["user_id"] result["signature"] = chsh["response"]["user_signature"] end end
key_for_crossinstall()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/crossinstall.rb, line 3 def key_for_crossinstall return_token_hash do agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE form = _g("https://secure.crossinstall.com/login").forms.first enter_login_details(form).submit.link_with(:text => " API Key"). click.search("input[name=api_key]").first.attributes["value"].value end end
key_for_leadbolt()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/leadbolt.rb, line 3 def key_for_leadbolt return_result_hash do |r| form = _g("https://www.leadboltnetwork.net/advertiser/login").forms.first enter_login_details(form).submit page = _g("https://www.leadboltnetwork.net/a/account/accountsettings") r["secret_key"] = page.search("div p[class=form-control-static]").last.text r["advertiser_id"] = page.search("div p[class=form-control-static]")[-2].text end end
key_for_loopme()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/loopme.rb, line 3 def key_for_loopme return_token_hash do form = _g("https://loopme.me/login").forms.first enter_login_details(form).submit page = _g("https://loopme.me/account/settings") page.search("span[id=api_auth_token]").first.children.first.text end end
key_for_mdotm()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/mdotm.rb, line 3 def key_for_mdotm return_result_hash do |result| agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE form = _g("https://platform.mdotm.com/app/login").forms.first page = enter_login_details(form).submit page = page.link_with(:text => "Your Profile").click { "account_id" => /AccountID.*<code>(.+)<\/code>/, "token" => /Your API Key.*<code>(.+)<\/code>/, "secret_key" => /Your Secret Key.*<code>(.+)<\/code>/ }.each do |key, regexp| page.content =~ regexp result[key] = $1 end end end
key_for_revmob()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/revmob.rb, line 3 def key_for_revmob return_result_hash do |result| _p("https://www.revmobmobileadnetwork.com/home/signIn",{ "emailSignIn" => params["username"], "pass" => params["password"], "originalUrl" => "/users/session/new"}) page = _p("https://www.revmobmobileadnetwork.com/myMedias",{ "countEnable" => "false", "filterText" => "", "limitEnd" => 15, "limitStart" => 15}) hsh = JSON.parse(page.content) result["user_id"] = hsh["user_id"] result["auth_token"] = hsh["auth_token"] end end
key_for_tapjoy()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/tapjoy.rb, line 3 def key_for_tapjoy return_token_hash do page = _p("https://dashboard.tapjoy.com/api/client/v1/session", { 'username' => params["username"], 'password' => params["password"], "_method" => "put"}) user_id = get_and_match(JSON.parse(page.content)["link"] + "/d", /User Id., "([^"]+)"/) page = _g("https://dashboard.tapjoy.com/api/client/users/#{user_id}") JSON.parse(page.content)["result"]["user"]["api_key"] end end
key_for_unilead()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/unilead.rb, line 3 def key_for_unilead return_token_hash do enter_login_details(_g("http://my.unileadnetwork.com/").forms.first). submit get_and_match("http://my.unileadnetwork.com/stats/stats_api", /Your API Key .+ <i>([^ ]+)[<]/) end end
key_for_vungle()
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers/vungle.rb, line 3 def key_for_vungle return_token_hash do csrf_token = get_and_match("https://v.vungle.com/dashboard/login", /id="csrf" value="([^"]+)"/) _p("https://v.vungle.com/dashboard/login", { "_csrf" => csrf_token, "email" => params["username"], "password" => params["password"]}) account_id = get_and_match("https://v.vungle.com/dashboard/reports", /"account":."_id":"([^"]+)"/) page = _g("https://v.vungle.com/dashboard/api/1/"+ "accounts/#{account_id}/users") JSON.parse(page.content).map {|a|a["secretKey"]}.compact.first end end
obtain_key_for(network, params)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 12 def obtain_key_for(network, params) @params = params send("key_for_#{network}") end
Protected Instance Methods
_g(url)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 24 def _g(url) agent.get(url) end
_p(url, data)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 28 def _p(url, data) agent.post(url, data) end
enter_login_details(form)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 48 def enter_login_details(form) form.fields. select { |a| a.name =~ /email/i }.first.value = params["username"] form.fields. select {|a| a.name =~ /passw(or)?d/i}.first.value = params["password"] form end
get_and_match(url, regexp)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 32 def get_and_match(url, regexp) _g(url).content =~ regexp && $1 end
post_and_match(url, data, regexp)
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 36 def post_and_match(url, data, regexp) _p(url, data).content =~ regexp && $1 end
return_result_hash() { |result| ... }
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 40 def return_result_hash(&block) {}.tap { |result| yield(result) } end
return_token_hash() { || ... }
click to toggle source
# File lib/adtekio_adnetworks/api_key_scrapers.rb, line 44 def return_token_hash(&block) return_result_hash { |r| r[:token] = yield } end