zoukankan      html  css  js  c++  java
  • 火车头采集标题如何伪原创(附教程)

    现在开发网站处理实现基本功能外,还要保证网站的收录率,实在很难!于是这个插件开发出来有一段时间了,看到小发猫AI,所以我就把我自己写的火车头伪原创插件写了一个正式版本,为从事网站优化、自媒体新入门的没有太多时间的同学增加一种选择,所以我发出一个开源的火车头伪原创插件希望大家支持!

    function get_ai_title($title) {
        $title = urlencode($title);
        $url = 'http://api.xiaofamao.com/aititle2/title.php?v=2&key=666&title='.$title; // 需要去小发猫AI开通
        $title_ai = curl_request($url);
        return $title_ai;
    }
    
    
    //参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
    function curl_request($url,$post='',$cookie='', $returnCookie=0){
        if (! extension_loaded('curl')) {
            file_exists('./ext/php_curl.dll') && dl('php_curl.dll'); // 加载扩展
        }
        
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');
        if (ini_get('open_basedir') == '' && strtolower(ini_get('safe_mode')) != 'on'){ 
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
        }
            curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
            curl_setopt($curl, CURLOPT_REFERER, "http://XXX");
            if($post) {
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
            }
            if($cookie) {
                curl_setopt($curl, CURLOPT_COOKIE, $cookie);
            }
            curl_setopt($curl, CURLOPT_HEADER, $returnCookie);
            curl_setopt($curl, CURLOPT_TIMEOUT, 150);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $data = curl_exec($curl);
            if (curl_errno($curl)) {
                return curl_error($curl);
            }
            curl_close($curl);
            if($returnCookie){
                list($header, $body) = explode("
    
    ", $data, 2);
                preg_match_all("/Set-Cookie:([^;]*);/", $header, $matches);
                $info['cookie']  = substr($matches[1][0], 1);
                $info['content'] = $body;
                return $info;
            }else{
                return $data;
            }
    }
    
    //API支持通过HTTP-POST方式访问,API地址为 http://nlp.xiaofamao.com/aititle2/title.php?json=0&v=1&key=xfmwriter
    //输入的post-data需要是TEXT格式,输出也是TEXT格式。 推荐使用Postman来查看API的结果。
    
    //接口调用演示地址:
    //http://nlp.xiaofamao.com/aititle2/api_form.php?json=0&key=xfmwriter

    我的其他文章:

    三大神经网络模型,神经网络简单实例

    CSS background-color 详细说明 ccs修改背景颜色

    神经网络的模型分为哪几类,神经网络训练模型描述

    python字符串替换函数,Python replace 示例源码

    计时器StopWatch的使用(附完整源码)

  • 相关阅读:
    快速幂求模
    elasticSearch入门
    springboot 停止
    gson
    jetty 入门
    redis工具
    oracle数据库操作
    Spring事务控制和回滚
    SPI
    PLSQLDeveloper_免安装自带client
  • 原文地址:https://www.cnblogs.com/python168/p/13915904.html
Copyright © 2011-2022 走看看