Guest User

Untitled

a guest
Oct 8th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?
  2.  
  3. $array = get_image_bing("winx club the movie in english");
  4.  
  5. $url = $array[0];
  6.  
  7.  
  8.  
  9. function get_image_bing($value)
  10. {
  11. GLOBAL $global_value, $image_bing_array, $image_bing_index, $image_bing_dir;
  12.  
  13. $value = iconv("windows-1251","utf-8",$value);
  14.  
  15. $content = my_curl("http://www.bing.com/images/search?scope=images&q=".urlencode($value)."&qft=+filterui:imagesize-medium&FORM=R5IR2","http://www.bing.com");
  16.  
  17. preg_match_all('!<a class="thumb" target="_blank" href="(.*?)"!siu',$content,$match);
  18.  
  19. $array = $match[1];
  20.  
  21. return ($array);
  22. }
  23.  
  24.  
  25. function my_curl($url, $referer, $browsers='Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.3)')
  26. {
  27. $ch = curl_init();
  28. curl_setopt($ch, CURLOPT_URL , $url);
  29. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  30. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  31. curl_setopt($ch, CURLOPT_REFERER, $referer);
  32. curl_setopt($ch, CURLOPT_COOKIE, 1);
  33. curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
  34. curl_setopt($ch, CURLOPT_USERAGENT , $browser);
  35. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // таймаут соединения
  36. curl_setopt($ch, CURLOPT_TIMEOUT, 30); // таймаут ответа
  37. curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // останавливаться после 10-ого редиректа
  38. curl_setopt($ch, CURLOPT_RETURNTRANSFER , true); //не выводить в поток
  39. curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true); //если редирект, то следовать
  40. $file = curl_exec($ch);
  41. curl_close($ch);
  42.  
  43. return ($file);
  44. }
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment