Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I've just spent an extremely frustrating Memorial Day holiday trying to find ways to select data on a web page via drop down boxes (date, report type) from a console app. I've tried HTMLDoc and HtmlAgilityPack with meager results. While scouring the web I discovered WebBrowser but found that this won't work through a console app. What I want to do is retrieve exchange settlement data on a daily basis from a website and convert it to .csv format and process it in my application. If anybody out there's done something similar and could give advice I'd greatly appreciate it. Thanks.
Posted

1 solution

Forget automating any web browser. You should know already that behind the scenes there is a communication between the browser and the web server conform a protocol named Hypertext Transfer Protocol (yes, that is http). Everything you do in the browser ends up in such a data exchange.
There is a class in the framework that you can use to simulate the browser activity directly on http level: HttpClient[^].
Simple samples: http://www.jayway.com/2012/03/13/httpclient-makes-get-and-post-very-simple/[^]
Complex samples http://blogs.msdn.com/b/webdev/archive/2012/08/26/asp-net-web-api-and-httpclient-samples.aspx[^]

Well, it depend on the web application you are trying to fetch, how complex this interaction will be. To get better knowing the process behind, I suggest you use Fiddler[^]. You will have to record your steps and examine the requests sent by the browser and the answers you get. If you are lucky, there is an ajax call for the content you are looking for. If not, you will need the Agility Pack you have already tried to process the result - when, and only when you have stepped trough the logic of the application.
 
Share this answer
 
Comments
Tom Paronis 27-May-13 16:59pm    
Zoltan; Thanks for your response. I've already mucked about a bit w HttpClient but didn't get too far. This seems simple in concept (selecting a date and getting data for it) and I'll definitely look through the samples and examine Fiddler. Right now I need a beer! Been a long day.
Zoltán Zörgő 27-May-13 17:09pm    
Can you give me the url?
Tom Paronis 27-May-13 17:48pm    
Sure. I want to get settlement data for certain dates. I'm a C++ financial apps guy who's not well versed in data scraping but I have to learn ASAP.

https://www.theice.com/marketdata/reports/ReportCenter.shtml#report/10

Getting settlements for certain contract/date combinations and converting them to .csv format is the ultimate goal here. Show me how and I'll buy you a beer when you come to New York. Here's how I have fun when I'm not wrestling with this stuff!
http://www.youtube.com/watch?v=tHTfv6_UP3w&list=PLRhrH4q6OOVYwJNct9uHWsn631mHNCx9r
Zoltán Zörgő 28-May-13 2:52am    
You said yourself, that you need to learn - I won't hinder you :). I examined the url you had given. This is an easy task. Follow the steps I suggested, and you will get your result. If you get stuck somewhere we are happy to help you, but we won't do the job for you. And the beer too will be yours.
Sergey Alexandrovich Kryukov 28-May-13 0:24am    
Good points, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900