Thread: Interacting with webpage from C program

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    7

    Interacting with webpage from C program

    Hello, i recently created a program and i want to add something similar like this to it which happens on program startup:

    Code:
    1. Program executes.
    2. Program checks "www.example.com" for a string on the webpage.
       3. if the string is there, continue running the program as normal.
       4. if the string is not there, the program closes.
    or

    Code:
    1. Program executes.
    2. Program checks "www.example.com/check.php" to see if check.php is there.
       3. if the check.php file is there, continue running the program as normal.
       4. if the check.php file is not there, the program closes.
    i've been searching google for a couple of hours and all i get is irrelevant results, first i'd like to know, is this possible with the standard C libraries that come installed with dev-cpp and second i'd like to know, if it is possible with the standard C libraries, which libraries would be used. If not, could someone point me to a library that would make this possible?

    thanks in advance.
    Last edited by Look-; 01-22-2008 at 02:59 PM.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Not with the standard libraries. Networking is not a part of standard C.

    You have a few choices,
    1. Use libcurl
    2. Use winsock (comes with dev-cpp) and the HTTP protocol

    IMO, I'd go with #2. Simply connect to the server, request the page -- then check the response (200OK or 404, etc).

    Good luck!

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You could also use a 3rd party application to do the HTTP work for you - like GNU wget.

    gg

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    7
    ok, thanks very much for the help guys, i guess i'll have a go at trying it with winsock

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. calling c++ program from a webpage
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-04-2001, 09:41 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM