nortmas
5/12/2014 - 8:27 AM

Curl

preg_match_all ("/<div class=\"main\">([^`]*?)<\/div>/", $data, $matches); // получает данные тега
preg_match_all("/\[\[([^`]*?)\]\]/", $value, $matches); // получает данные медиа тега
function curl_pull_file($url) {

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 160);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 240);
  curl_setopt($ch, CURLOPT_COOKIEJAR, "tmp/" . $machine_name . "_resume_cookie.txt");
  curl_setopt($ch, CURLOPT_COOKIEFILE, "tmp/" . $machine_name . "_resume_cookie.txt");
  $data = curl_exec($ch);
  curl_close($ch);
  file_put_contents($filename, $data);

  if ($data) {
    drupal_set_message('Success');
  }
  else {
    drupal_set_message("Error.", 'error');
  }
}