Advertisement
Guest User

Untitled

a guest
May 26th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. function curl($url,$post=""){
  4.  
  5. //echo $url;
  6. $c=curl_init();
  7. curl_setopt($c, CURLOPT_URL, $url);
  8. curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0');
  9. curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  10. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
  11. curl_setopt($c, CURLOPT_TIMEOUT, 35);
  12. curl_setopt($c, CURLOPT_COOKIEJAR, './c.txt');
  13. curl_setopt($c, CURLOPT_COOKIEFILE, './c.txt');
  14. //curl_setopt($c, CURLOPT_PROXY, 'socks5://localhost:9999');
  15. if($post!=""){
  16. curl_setopt($c, CURLOPT_POST, 1);
  17. curl_setopt($c, CURLOPT_POSTFIELDS, $post);
  18. }
  19. curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  20. $rez=curl_exec($c);
  21.  
  22. return $rez;
  23.  
  24. }
  25. $rez=curl('https://en.wikipedia.org/w/api.php?action=opensearch&format=json&formatversion=2&search=php&namespace=0&limit=10&suggest=true');
  26. $js=json_decode($rez);
  27.  
  28. //Link-urile se afla pe a 3-a ramura
  29. $link=$js[3][2]; //Al treilea link
  30.  
  31.  
  32. $rez=curl($link);
  33. file_put_contents('test.html', $rez);
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement