Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function curl($url,$post=""){
- //echo $url;
- $c=curl_init();
- curl_setopt($c, CURLOPT_URL, $url);
- curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0');
- curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($c, CURLOPT_TIMEOUT, 35);
- curl_setopt($c, CURLOPT_COOKIEJAR, './c.txt');
- curl_setopt($c, CURLOPT_COOKIEFILE, './c.txt');
- //curl_setopt($c, CURLOPT_PROXY, 'socks5://localhost:9999');
- if($post!=""){
- curl_setopt($c, CURLOPT_POST, 1);
- curl_setopt($c, CURLOPT_POSTFIELDS, $post);
- }
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
- $rez=curl_exec($c);
- return $rez;
- }
- $rez=curl('https://en.wikipedia.org/w/api.php?action=opensearch&format=json&formatversion=2&search=php&namespace=0&limit=10&suggest=true');
- $js=json_decode($rez);
- //Link-urile se afla pe a 3-a ramura
- $link=$js[3][2]; //Al treilea link
- $rez=curl($link);
- file_put_contents('test.html', $rez);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement