fork download
  1. <?php
  2. $postFieldsLogin = require ('config.php');
  3. $assembleStr = function($array){
  4. $str = '';
  5. foreach($array as $key => $value) {
  6. $str.= $key . '=' . $value . '&';
  7. }
  8. return $str = rtrim($str, '&');
  9. };
  10. $domain = 'https://w...content-available-to-author-only...e.ru';
  11. $linkLogin = '/Account/Login';
  12. $linkGetCsv = '/GetItems/Content?=&';
  13. $todayMinusDays = 1;
  14. $searchSubStr = 'Здравствуйте';
  15. $cookie = 'cookie.txt';
  16. $csv = 'content.csv';
  17. $log = 'log.log';
  18. $data = $fieldsString = '';
  19. $sep = "\n";
  20. $timesOfRepeatSep = 2;
  21. $sleepTime = 180;
  22. $postFieldsGetCsv = [
  23. 'account' => '',
  24. 'beginDate' => date('d.m.Y',
  25. (strtotime('-'. $todayMinusDays .' day', strtotime(date('r'))))) ,
  26. 'endDate' => date('d.m.Y')
  27. ];
  28. //truncate files
  29. file_put_contents($cookie, '');
  30.  
  31. do {
  32. /*initial login request*/
  33. $ch = curl_init();
  34. curl_setopt($ch, CURLOPT_URL, $domain . $linkLogin);
  35. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  36. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  37. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  38. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  39. curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  40. curl_setopt($ch, CURLOPT_HEADER, 1);
  41. $fieldsString = $assembleStr($postFieldsLogin);
  42. curl_setopt($ch, CURLOPT_POST, count($postFieldsLogin));
  43. curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
  44. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
  45. curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  46. $data.= str_repeat($sep, $timesOfRepeatSep) . trim(curl_exec($ch));
  47. $data.= str_repeat($sep, $timesOfRepeatSep) . trim($fieldsString);
  48. file_put_contents($log, trim($data), FILE_APPEND);
  49. if (mb_strpos($data, $searchSubStr)) {
  50. $isLogin = true;
  51. /*another request for getting formatted content*/
  52. curl_setopt($ch, CURLOPT_URL, $domain . $linkGetCsv);
  53. $fieldsString = $assembleStr($postFieldsGetCsv);
  54. curl_setopt($ch, CURLOPT_POST, count($postFieldsGetCsv));
  55. curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
  56. $result = curl_exec($ch);
  57. curl_close($ch);
  58. $data.= str_repeat($sep, $timesOfRepeatSep) . trim($result);
  59. $data.= str_repeat($sep, $timesOfRepeatSep) . trim($fieldsString);
  60. file_put_contents($csv, $result);
  61. file_put_contents($log, trim($data), FILE_APPEND);
  62. }
  63. else {
  64. $data.= str_repeat($sep, $timesOfRepeatSep) .
  65. trim($sleepTime . " SECS DELAY") . str_repeat($sep, $timesOfRepeatSep);
  66. file_put_contents($log, trim($data), FILE_APPEND);
  67. sleep($sleepTime);
  68. }
  69. }
  70. while (!$isLogin);
Runtime error #stdin #stdout #stderr 0.03s 52480KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  require(config.php): failed to open stream: No such file or directory in /home/CkcWbd/prog.php on line 3
PHP Fatal error:  require(): Failed opening required 'config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/CkcWbd/prog.php on line 3