/sampleScripts/kenexa.php
PHP | 48 lines | 29 code | 0 blank | 19 comment | 1 complexity | 7c9056121eeb49277c50f623b67a8d3d MD5 | raw file
- <?php
- require_once('ripcurl.class.php');
- //Instantiate ripcurl object
- $rip = new ripcurl();
- //Fetch initial page for cookie and session data
- $rip->ripRun('https://recruiter.kenexa.com/providence/cc/Home.ss?ccid=bupJEdUjsTs%3D',1);
- //Hidden form so let's grab that data since everything is a form submit
- $elements = $rip->getFormElements('form');
- //Assign out ccid since that seems to be used a lot
- $ccid = urlencode($elements['ccid']);
- //Fetch second page - Search Page
- $rip->ripRun('https://recruiter.kenexa.com/providence/cc/CCJobSearchAction.ss?command=CCSearchPage&ccid='.$ccid, 1, $elements);
- //Grab form data again
- $elements = $rip->getFormElements('form');
- //Set result page url since this might chnge with pagination
- $url = 'https://recruiter.kenexa.com/providence/cc/CCJobSearchAction.ss?command=CCSearchNow';
- //Begin pagination
- do{
- //Save initial result for pagination test later
- $html = $rip->ripRun($url, 1, $elements);
- //Grab form data again
- $elements = $rip->getFormElements('form');
- //Grab jobs
- $jobs = $rip->getWeirdLinks('job_JOB_TITLE_ID_onClick');
- //Need just the jobid
- foreach($jobs as $job){
- $jobid = $rip->ripInBetween("'", "'", null, $job);
- //Change value of this element to job id
- $elements['job_REQUISITION_NUMBER'] = $jobid[0];
- //Get job page
- $rip->ripRun('https://recruiter.kenexa.com/providence/cc/CCJobResultsAction.ss?command=ViewJobDetails&job_REQUISITION_NUMBER='.$jobid[0], 1, $elements);
- //Echo out the job
- echo $rip->getRawHtml();
- }
- //Check if there is a next page and set the proper variables
- if(preg_match('|<a(.*?)image91(.*?)</a>|', $html, $matches)){
- //Grab next page number and assign it to POST PageNumber
- $page = $rip->ripInBetween('\(', '\)', null, $matches[1]);
- $page = $page[0];
- $elements['PageNumber'] = $page;
- //Construct URL for next page
- $url = 'https://recruiter.kenexa.com/providence/cc/CCJobResultsAction.ss?command=MoveToPage';
- }else{
- //Next page not found, make null to break the loop
- $url = null;
- }
- }while(!is_null($url));
- ?>