当前位置:首页 > PHP > 正文内容

php调用谷歌无头浏览器访问网页+推送百度(代码备份)

高老师6年前 (2021-01-19)PHP2093

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://blog.20230611.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增加收录

扫描二维码推送至手机访问。

版权声明:本文由高久峰个人博客发布,如需转载请注明出处。

本文链接:https://blog.20230611.cn/post/193.html

分享给朋友:

“php调用谷歌无头浏览器访问网页+推送百度(代码备份)” 的相关文章

php 开启错误提示,php 关闭错误提示

php 开启错误提示,php 关闭错误提示

开启错误提示代码:ini_set("display_errors", "On"); error_reporting(E_ALL | E_STRICT);关闭错误提示代码:error_reporting(E_ALL ^&n...

php scoket,php webscoket,php webscoket 服务器

php scoket,php webscoket,php webscoket 服务器

项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...

php使用swoole扩展推送消息

php使用swoole扩展推送消息

通过http推送消息给socket,socket服务再向客户端推送<?php /*  * Socket推送  * 请用守护进程方式启动php msgservice.php &   (socket只...

抛弃salt,使用password_hash()加密

抛弃salt,使用password_hash()加密

md5/sha1+salt方式是目前各大cms常用的加密方式,虽然salt安全,但是各大md5网站也在研究这个方向,那么我们应该选择password_hash动态hash来助力,一种密码有多种hash结果.看代码模拟登陆.<?php //01.注册 $user ='zhang...

PHP二维数组排序,PHP多维数组排序, array_multisort()

PHP二维数组排序,PHP多维数组排序, array_multisort()

使用php函数array_multisort()即可实现和SQL一样的order by排序. 例如我们需要对会员表按照主键降序排列,年龄升序排列://会员表数据 $list = []; $list[] = ['mid' =>&n...

php json_encode 使用注意

php json_encode 使用注意

参数中包含gb2312的字符串,返回结果是false或者null(不同PHP版本具有差异性)代码:<?php $dbms = 'mysql'; $host = '192.168.8.8'; $dbName =&n...