PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/sampleScripts/kenexa.php

https://bitbucket.org/linuxdream/ripcurl
PHP | 48 lines | 29 code | 0 blank | 19 comment | 1 complexity | 7c9056121eeb49277c50f623b67a8d3d MD5 | raw file
  1. <?php
  2. require_once('ripcurl.class.php');
  3. //Instantiate ripcurl object
  4. $rip = new ripcurl();
  5. //Fetch initial page for cookie and session data
  6. $rip->ripRun('https://recruiter.kenexa.com/providence/cc/Home.ss?ccid=bupJEdUjsTs%3D',1);
  7. //Hidden form so let's grab that data since everything is a form submit
  8. $elements = $rip->getFormElements('form');
  9. //Assign out ccid since that seems to be used a lot
  10. $ccid = urlencode($elements['ccid']);
  11. //Fetch second page - Search Page
  12. $rip->ripRun('https://recruiter.kenexa.com/providence/cc/CCJobSearchAction.ss?command=CCSearchPage&ccid='.$ccid, 1, $elements);
  13. //Grab form data again
  14. $elements = $rip->getFormElements('form');
  15. //Set result page url since this might chnge with pagination
  16. $url = 'https://recruiter.kenexa.com/providence/cc/CCJobSearchAction.ss?command=CCSearchNow';
  17. //Begin pagination
  18. do{
  19. //Save initial result for pagination test later
  20. $html = $rip->ripRun($url, 1, $elements);
  21. //Grab form data again
  22. $elements = $rip->getFormElements('form');
  23. //Grab jobs
  24. $jobs = $rip->getWeirdLinks('job_JOB_TITLE_ID_onClick');
  25. //Need just the jobid
  26. foreach($jobs as $job){
  27. $jobid = $rip->ripInBetween("'", "'", null, $job);
  28. //Change value of this element to job id
  29. $elements['job_REQUISITION_NUMBER'] = $jobid[0];
  30. //Get job page
  31. $rip->ripRun('https://recruiter.kenexa.com/providence/cc/CCJobResultsAction.ss?command=ViewJobDetails&job_REQUISITION_NUMBER='.$jobid[0], 1, $elements);
  32. //Echo out the job
  33. echo $rip->getRawHtml();
  34. }
  35. //Check if there is a next page and set the proper variables
  36. if(preg_match('|<a(.*?)image91(.*?)</a>|', $html, $matches)){
  37. //Grab next page number and assign it to POST PageNumber
  38. $page = $rip->ripInBetween('\(', '\)', null, $matches[1]);
  39. $page = $page[0];
  40. $elements['PageNumber'] = $page;
  41. //Construct URL for next page
  42. $url = 'https://recruiter.kenexa.com/providence/cc/CCJobResultsAction.ss?command=MoveToPage';
  43. }else{
  44. //Next page not found, make null to break the loop
  45. $url = null;
  46. }
  47. }while(!is_null($url));
  48. ?>