Ajax crawl issue

#1

I have been trying to crawl

http://www.oildirectory.com/site/search/index.php?full_category=Oil+%26+Gas+Producers

But on ajax they call http://www.oildirectory.com/site/search/index.php and passess the post data . I have tried but not luck , i want to search for Oil & Gas Producers only.

function pageFunction(context) {

var $ = context.jQuery;
var full_category = "Oil & Gas Producers";
page_no =3;
context.enqueuePage({
     url: "http://www.oildirectory.com/site/search/index.php",
     postData: {
                  full_category:full_category,
                  page_no:3,
                  new_page_no:{'0':2,'1':2},
                  old_page_no:{'0':1,'1':2}
             },
     method:"POST"
});
var oil_directory = []; 
$('.top').each(function(){

     var oil_company_name = $(this).find('#ad-name').text().trim(); 
     var location         = $(this).find('#ad-location').text().trim();
     var contact          = $(this).find('#ad-category').text().trim();
     
      var obj = {
         
         oil_company_name:oil_company_name,
         location:location,
         contact:contact
        
     }
    oil_directory.push(obj);      
});

return oil_directory;

}

For second page i get home page results

[{
“loadedUrl”: “http://www.oildirectory.com/site/search/index.php”,
“loadingStartedAt”: “2018-04-30T10:13:41.935Z”,
“loadingFinishedAt”: “2018-04-30T10:13:51.361Z”,
“pageFunctionStartedAt”: “2018-04-30T10:13:52.148Z”,
“pageFunctionFinishedAt”: “2018-04-30T10:13:52.155Z”,
“postData”: “[object Object]”,
“method”: “POST”,
“pageFunctionResult”: [

#2

Hi @virtualqube,

in this case, you need to encode string from post data otherwise it doesn’t work.

var full_category = encodeURI('Oil & Gas Producers');

Or you can put params in url and use GET request instead of POST, like:
http://www.oildirectory.com/site/search/index.php?full_category=Oil+%26+Gas+Producers&page_no=3