curl-and-python

Problems posting data with PycURL

From: Matthew Miller <millsmtm_at_gmail.com>
Date: Thu, 28 Apr 2011 15:31:31 -0400

I've been assigned a task where I have to navigate through the Georgia
Medicaid website (www.mmis.georgia.gov) and eventually end up downloading
files. My current problem however is that after I log in, I then have to
select which user I am from a list. The problem I'm currently having is that
after you would select your user in a browser, a javascript confirmation box
appears where you have to confirm. I've used Live HTTP headers and Firebug
to get all of the post data, however my program is still failing to actually
select and confirm the user.

The following is what I currently have.

# Setting up the PycURL options
c.setopt(c.SSL_VERIFYPEER, False)
c.setopt(c.COOKIEJAR, cookieFile) # The file for cookieFile is
previously declared in the program (It's storing cookies fine)
c.setopt(c.FOLLOWLOCATION, 1)
c.setopt(c.POST, 1)
c.setopt(c.VERBOSE, 1)

# Navigates to the login page
# Theres an incredibly long string for __VIEWSTATE that I have taken out for
readability
# From everything I can tell, my login seems to be working and going
smoothly

c.setopt(c.URL, '
https://sso.gammis.com/adfs/ls/?wa=wsignin1.0&wreply=https%3a%2f%2fhome.gammis.com%2fhome%2f&wct=2011-04-27T14%3a00%3a55Z&wctx=aa8fd51f-12f7-449a-b997-542f54061e9b
')
postField = ('__EVENTTARGET='
                 '&__EVENTARGUMENT='
                 '&__VIEWSTATE='
                 '&ctl00%%24ContentPlaceHolder1%%24txtUsername=%s' %
urllib.quote(username) +
                 '&ctl00%%24ContentPlaceHolder1%%24txtPassword=%s' %
urllib.quote(password) +
                 '&ctl00%24ContentPlaceHolder1%24btnSignIn=Sign+In')
c.setopt(c.POSTFIELDS, postField)
c.perform()

# Now the part that is seemingly not working, the switching of the users
# Selecting the user (XXXXXXXXX obviously isn't what is actually there)
c.setopt(c.URL, '
https://www.mmis.georgia.gov/portal/Account/Switch%20Provider/tabId/97/Default.aspx
')
postField =
[('__EVENTTARGET','dnn%24ctr571%24SwitchProviderPage%24_ctl5%24Datalist%24_ctl3%24Select'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24Name%24mb_Name','XXXXXXXXX'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24UserName%24mb_UserName','XXXXXXXXX'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24UserType%24mb_UserType','XXXXXXXXX'),
                 ('dnn%24ctr571%24SwitchProviderPage%24n1_allowClose','0'),
                 ('dnn%24ctr571%24SwitchProviderPage%24n2_allowClose','0')]
c.setopt(c.HTTPPOST, postField)
c.perform()

# Confirming the selection (Clicking 'Ok' on the javascript popup)
c.setopt(c.POSTFIELDS, '')
c.setopt(c.URL, '
https://www.mmis.georgia.gov/portal/Account/Switch%20Provider/tabId/97/Default.aspx
')
postField =
[('__EVENTTARGET','dnn%24ctr571%24SwitchProviderPage%24_ctl5%24CriteriaPanel%24ConfirmationPositiveResponse'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24Name%24mb_Name','XXXXXXXXX'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24UserName%24mb_UserName','XXXXXXXXX'),

('dnn%24ctr569%24UserInfoPage%24UserInfoPanel%24_ctl2%24_ctl0%24UserType%24mb_UserType','XXXXXXXXX'),
                 ('dnn%24ctr571%24SwitchProviderPage%24n1_allowClose','0'),
                 ('dnn%24ctr571%24SwitchProviderPage%24n2_allowClose','0')]
c.setopt(c.HTTPPOST, postField)
c.perform()

Please help :(

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2011-04-28