Created
May 18, 2009 19:00
-
-
Save philcrissman/113676 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class InterpokerImporter < Importer | |
LOGIN_URI = URI.parse("https://www1.ireferrer.com/C2/00/index.ehtml?Alias=rtback&Password=toesline&UserID=3042407&action=login") | |
ENTER_URI = URI.parse("https://www1.ireferrer.com/C2/00/enter.shtml") | |
AFFILIATE_URI = URI.parse("https://www1.ireferrer.com/C2/00/affiliate.shtml") | |
LOGIN2_URI = URI.parse("https://www1.ireferrer.com/C2/00/login2.shtml") | |
STATS_URI = URI.parse("https://www1.ireferrer.com/C2/00/comm_poker_detail.csv") | |
USER_AGENT = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' | |
def initialize | |
super | |
@affiliate = get_affiliate(8) | |
end | |
def load | |
# ymd | |
ymd = 1.day.ago.strftime("%Y%m%d") | |
# Comments in the php version of this importer warn that we | |
# should NOT run it on the 2nd day of the month; it will pick up | |
# previous months stats. | |
if 1.day.ago.strftime("%d") == "02" | |
raise "Interpoker Importer cannot be run on the 2nd day of the month" | |
end | |
# http setup | |
http = Net::HTTP.new(LOGIN_URI.host, LOGIN_URI.port) | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
http.use_ssl = true | |
# login | |
# req = Net::HTTP::Post.new(LOGIN_URI.request_uri) | |
headers = { | |
'User-Agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3 GT B5', | |
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
'Accept-Language' => 'en-us,en;q=0.5', | |
'Accept-Encoding' => 'gzip,deflate', | |
'Keep-Alive' => '300', | |
'Connection' => 'keep-alive', | |
'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
'Cookie' => 'Alias=rtback; UserName=deleted; acc_no=03042407; CP=null*' | |
} | |
req = Net::HTTP::Get.new(LOGIN_URI.request_uri, headers) | |
# The PAS importer doesn't actually use post variables, | |
# instead uses them as in the request_uri (see LOGIN_URI) !!?? | |
# Lets try it anyways. | |
# req.set_form_data( | |
# :UserID => @affiliate.importer_user, | |
# :Password => @affiliate.importer_password, | |
# :Alias => @affiliate.importer_extra | |
# ) | |
res = http.request(req) | |
cookie = 'Alias=rtback; UserName=deleted; acc_no=03042407; CP=null*' | |
find_next_1 = res.body.split("goToURL('login_form.shtml?") | |
find_next_2 = find_next_1[1].split("');") | |
next_url_query = find_next_2[0] | |
key = next_url_query.split('&key=')[1] | |
# go to next url | |
next_request_uri = "/C2/00/login_form.shtml?" + next_url_query | |
req = Net::HTTP::Get.new(next_request_uri, headers) | |
res = http.request(req) | |
# now enter_uri | |
req = Net::HTTP::Post.new(ENTER_URI.path)#, headers) | |
req.set_form_data( | |
:UserId => @affiliate.importer_user, | |
:Password => @affiliate.importer_password, | |
:Alias => @affiliate.importer_extra, | |
:key => key | |
) | |
res = http.request(req) | |
puts res.body | |
raise "stop" | |
# affiliate uri | |
req = Net::HTTP::Post.new(AFFILIATE_URI.path, headers) | |
req.set_form_data( | |
:key => key | |
) | |
res = http.request(req) | |
res.each {|x,y| puts x + ': ' + y } | |
# login2 w/GET | |
# query = { :key => key }.to_param | |
# puts query | |
# req = Net::HTTP::Get.new(LOGIN2_URI.path + '?' + query) | |
# res = http.request(req) | |
# # | |
# # stats | |
query = { :key => key, :Month => 'Current' }.to_param | |
req = Net::HTTP::Get.new(STATS_URI.path + '?' + query, headers) | |
res = http.request(req) | |
# # https://www1.ireferrer.com/C2/00/comm_poker_detail.csv?key='.$formvars['key'].'&Month='.$month_to_use | |
end | |
def parse(raw_data) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment