I get redirected to a page with address like http://example.com#foo=bar
. I want to get foo=bar
part of it. The whole thing would be ok too.
I found this thing:
char * url;
curl_easy_getinfo(myHandle, CURLINFO_EFFECTIVE_URL, &url);
I don't know english well to find information myself. Every time I want to find it, I find information on getting the page into string variable.
Code:
std::string readBuffer;
curl_global_init( CURL_GLOBAL_ALL);
CURL * myHandle;
CURLcode result;
myHandle = curl_easy_init();
curl_easy_setopt(myHandle, CURLOPT_COOKIEJAR, "coo.txt");
curl_easy_setopt(myHandle, CURLOPT_COOKIEFILE, "coo.txt");
curl_easy_setopt(myHandle, CURLOPT_URL, "https://www.google.ru/#q=stack");
curl_easy_setopt(myHandle, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(myHandle, CURLOPT_FOLLOWLOCATION, 1L);
result = curl_easy_perform(myHandle);
char * ch_cur_url;
result = curl_easy_getinfo(myHandle, CURLINFO_EFFECTIVE_URL,
&ch_cur_url);
printf("%s\n", ch_cur_url);
Outputs https://www.google.ru/
When I wanted https://www.google.ru/#q=stack