美文网首页
百度收录查询源代码

百度收录查询源代码

作者: 诗无尽头i | 来源:发表于2018-08-28 17:02 被阅读29次
    function baidu_check($url) {
        global $wpdb;
        $post_id = (null === $post_id) ? get_the_ID() : $post_id;
        $baidu_record = get_post_meta($post_id, 'baidu_record', true);
        if ($baidu_record != 1) {
            $url = 'http://www.baidu.com/s?wd=' . $url;
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $rs = curl_exec($curl);
            curl_close($curl);
            if (!strpos($rs, '没有找到')) {
                if ($baidu_record == 0) {
                    update_post_meta($post_id, 'baidu_record', 1);
                } else {
                    add_post_meta($post_id, 'baidu_record', 1, true);
                }
                return 1;
            } else {
                if ($baidu_record == false) {
                    add_post_meta($post_id, 'baidu_record', 0, true);
                }
                return 0;
            }
        } else {
            return 1;
        }
    }
    

    相关文章

      网友评论

          本文标题:百度收录查询源代码

          本文链接:https://www.haomeiwen.com/subject/zmsqwftx.html