mercredi 5 mai 2021

Input data to postfield, click search, extract the output. All using libcurl c++

I have a website(ntorder) which shows product data. I have an extension of downloading the cookies of any site. When I login in to (ntorder site), i get the cookies through extension.

After logging in, I have to go to a page which looks like this

enter image description here

I want to send a BARCODE in the Postfield (Search For), and then search for that barcode all using libcurl c++. . here is what i did untill now

curl_global_init(CURL_GLOBAL_DEFAULT);
std::ostringstream stream;
curl = curl_easy_init();
if(curl)
{
    std::ostringstream oss;
    std::string s;
    std::string url = "https://www.ntorder.com/app_presentation/productcatalogue/default.aspx" ;
    std::string username = std::string("BARCODE HERE");
 
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36");
    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies_nisa.txt"); //this text file has cookies
    
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    
    res = curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);
    //std::cout<<s<<"\n\n";
    if(CURLE_OK != res) 
    {
        /* we failed */
        std::cerr << "curl told us " << res << '\n';
    }
    std::cout<<s;

When i got the result, there was nothing, i think it didn't even accept my login through cookies file. Anyone can help?

Aucun commentaire:

Enregistrer un commentaire