curl-library
help with novice program
Date: Tue, 10 Aug 2010 19:33:23 +0100
Hi, I am trying to write a simple program in C++ that obtains user input of a string.
The curl library is then used to make a connection to a given website and then - if possible search for all occurance of the given string. My questions are:
1. Is it essential to transfer a copy of the online resource before searching for the expression? Could my program search the online resource remotely?
2. This is the simple code i have written so far:
#include <string>
#include <iostream>
#include <curl/curl.h>
using namespace std;
// simple program to obtain user input of a string, connect to a website to search for occurances of
// the string
int main()
{
int end(1);
while (end != 0)
{
// Initialisation of curl
curl_global_init(CURL_GLOBAL_ALL);
std::string myword;
cout << "Input a word to search for \n";
cin >> myword;
cout << "Searching for occurances of " << myword << endl;
// insert connection and search code here
// which website?
// look for myword
cout << "Do you wish to search again? ENTER 0 to end or 1 to search again\n";
cin >> end;
if (end == 0)
return 0;
};
curl_global_cleanup();
}
Now suppose I wish to search the URL www.bbc.co.uk for all occurances of the string myword, how would I actually code this? Im not even sure that the code i have written properly invokes curl, though it does compile. Any suggestions would be welcome. Once i get this program working, i will feel more confident in experimenting further.
Many thanks
neil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-10