AMM
AMM

Reputation: 17920

c++ program to read a table from a web page

I need to write a c++ program that gets data from a web page (i have the url to that). Basically the web page contains a huge table spread over multiple pages (though next buttons).

I need to get this entire table and then take each row and parse it (table has around 10 columns). Each of this has to be put into a csv file in a similar data format after some minor processing.

Can anybody suggest the best way to do this. I need to do this in c++ am wondering what libs i shd use. Needs to be done in windows but i dont mind using platform independent / dependent stuff.

Thanks in advance.

Upvotes: 0

Views: 1825

Answers (2)

pmr
pmr

Reputation: 59811

Let libcurl do the downloading for you. It's fast and you don't have to deal with HTTP directly.

There are many libraries out there for parsing XML in C++. See this.

Do everybody a favour and don't try to parse HTML with a regexp. You will summon Cthulhu.

Upvotes: 2

Drahakar
Drahakar

Reputation: 6078

I know that this might not be the exact answer you are looking for, but since it is an option...

You could generate a basic HTTP GET with a raw socket and then you would receive your table in HTML format. You would then only have to parse it (using an XML parser or manualy looking for the table or a specific ID) and get your results.

I know this is not the best and "ready to use" solution, but still it could work.

Upvotes: 0

Related Questions