Thread: Grabbing HTML

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    3

    Grabbing HTML

    Hello,

    Im new to C/C++ and Im not sure how to approch this,

    At work every so often I need to review a log file displayed to me in an html table, and look through it for certain things, however this log is not sorted! (and I do not have any access to the server).

    I would like to save myself some time, and make a small program to download the file, sort it, and display what is relevant to me in the correct order.

    Sorting it is straight forward if I can get it into a string, but how do I download/grab the html?

    Im not really sure exactly what Im looking for here, and my searching hasn't been very rewarding as a result.



    Do you know of any straight forward ways to approch this?
    (Any url's or tiny examples much appreciated!)

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    22
    You require sockets/network programming.

    A good tutorial exists here:
    http://www.ecst.csuchico.edu/~beej/guide/net/

    For windows specific(WINSOCK) you can read this:
    http://www.hal-pc.org/~johnnie2/winsock.html

    Windows specific again, higher level programming interfaces exist such as:
    http://msdn.microsoft.com/library/de...classtopic.asp
    (requires .NET framework)


    In summary, google for "network programming" "socket programming" "winsock".

    Goodluck

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    wget (or another URL grabbing tool of your choice - there are several) to get the HTML
    perl to munch the file looking for things which interest you.

    Doing the whole thing in C++ would be tedious, unless that's the whole point of the exercise (learning).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    3
    Thank you!, my mistake was assuming there would be an easier way then sockets.


    For future reference if anyone wants to do this, I have found the easiest way to be following Salems advice and using WGET to fetch the html, so it can then be processed locally.

    There is a windows port of WGET with C source here: http://www.interlog.com/~tcharron/wgetwin.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 07:36 PM
  2. Writing an HTML Preprocessor
    By thetinman in forum C++ Programming
    Replies: 1
    Last Post: 09-17-2007, 08:01 AM
  3. Stacks, classes, HTML tags, and parsing.
    By Shinobi-wan in forum C++ Programming
    Replies: 5
    Last Post: 10-01-2003, 05:50 PM
  4. Design + HTML
    By orbitz in forum C Programming
    Replies: 8
    Last Post: 11-21-2002, 06:32 AM