Archived

This topic is now archived and is closed to further replies.

laeuchli

Extracting links form html source.

Recommended Posts

laeuchli    338
Dear All, I''m trying to figure out how to write a function that will return the html links from a string containing html code. I''m not sure which C string functions to use. My first thought was to use strtok, but that doesn''t seem to work. Does anyone have any suggestions on how to go about this? Thanks, Jesse

Share this post


Link to post
Share on other sites
Oluseyi    2103
C: strstr
C++: std::string::find
Perl/Python: REs (much faster, and standard with the language)

One thing to give thought to is to grab the HTML file, prepend some j''script to it in just the right place and use that script to dump the links (which should be nicely stored in an array whose name I forget).

Share this post


Link to post
Share on other sites
kuphryn    210
Yes, extracting HTML links from source files is not difficult using pure C/C++. As the other member has mentioned, one solution is to store the source file in a string object and analyze each section accordingly.

Kuphryn

Share this post


Link to post
Share on other sites