Skip to content Skip to sidebar Skip to footer

Failed To Screen Scrape Asp.net Website While Posting Data

Getting Invalid postback or callback argument error while trying to screen scrape a website which has build on ASP.NET. Fist request of landing page has no issue. It's raising exce

Solution 1:

You where basically on the right track. I got it running with a few changes.

Invalid postback or callback argument.

The error message is really helpful. If you read the msdn page of it there is a hint.

Summarized as: don't post parameters or values which are not in the form which you get with GET

In your case means that that if you select a State it should be one of the values from cboState select element. (For example 2 is not a valid value)

But this is right in your example so the second point is not to have parameters in your post request which are not valid. Meaning in this example you shouldn't add cboCity when you post to __EVENTTARGET cboState.

Long story short you need to use this form fields:

FORM_FIELDS = {
    '__EVENTTARGET': 'cboState',
    '__EVENTARGUMENT': '',
    '__LASTFOCUS': '',
    '__VIEWSTATE': view_state,
    '__VIEWSTATEGENERATOR': view_state_generator,
    '__EVENTVALIDATION': event_validation,
    'cboState': '3',
    'hdDealerMaps': 'True',
}

The updated version of the script: https://gist.github.com/fliiiix/ea365b96f5ab4ec4d345

Post a Comment for "Failed To Screen Scrape Asp.net Website While Posting Data"