Parse a .Net Page with Postbacks

后端 未结 3 1880
孤独总比滥情好
孤独总比滥情好 2020-12-20 09:57

I need to read data from an online database that\'s displayed using an aspx page from the UN. I\'ve done HTML parsing before, but it was always by manipulating query-string

相关标签:
3条回答
  • 2020-12-20 10:48

    You may still only need to send one request, but that one request can be rather complicated. ASP.Net is notoriously difficult (though not impossible) to screen scrape. Between event validation and the ViewState, it's tricky to get your requests just right. The simplest way to do it is often to use a sniffer tool like fiddler to see exactly what the http request looks like, and then just mimic that request.

    If you do still need to send two requests, it's because the first request also places some state in a session somewhere, and that means whatever you use to send those requests needs to be able to send them with the same session. This often means supporting cookies.

    0 讨论(0)
  • 2020-12-20 10:55

    I'd look at HtmlAgilityPack with the FormProcessor addon.

    0 讨论(0)
  • 2020-12-20 10:56

    Watin would be my first choice. You would code the selecting and clicking, then parse the HTML after.

    0 讨论(0)
提交回复
热议问题