php调用谷歌无头浏览器访问网页(代码备份):
<?php $i = 1403; while ($i--) { $url = "https://wap.xingxinghan.cn/?id=" . $i; $cmd = "chrome --headless --disable-gpu $url"; echo $url . PHP_EOL; exec($cmd); sleep(10); push($url); } function push($url) { $urls = array( $url, ); $api = 'http://data.zz.baidu.com/urls?site=https://wap.xingxinghan.cn&token=JFlzEXUDAXAZDvXyZl2'; $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("\n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); echo $result . PHP_EOL; } <?php while(true) { $response = file_get_contents('http://learn.gaojiufeng.cn/index/test1x/showId'); $response = json_decode($response); foreach ($response as $key => $value) { $url = "https://www.gaojiufeng.cn/?id=" . $value; $cmd = "chrome --headless --disable-gpu --window-size=1920x1080 $url"; echo $url . PHP_EOL; echo $cmd . PHP_EOL; exec($cmd); sleep(15); } }
目的:刷真实PV增加收录