在Pipelines中新建以下类

class PostApiPipeline(object):
    async def process_item(self, item, spider):
        request=scrapy.Request("xxxx/api.php", method="POST", body=json.dumps(dict(item)), headers={'Content-Type': 'application/json'})
        response = await spider.crawler.engine.download(request, spider)
        return item

原查询方式

<?php
require('e/class/connect.php');        //引入数据库配置文件和公共函数文件
require('e/class/db_sql.php');        //引入数据库操作文件
$link=db_connect();                //连接MYSQL
$empire=new mysqlquery();        //声明数据库操作类

$sql=$empire->query("select * from {$dbtbpre}ecms_news order by newstime limit 10");        //查询新闻表最新10条记录
while($r=$empire->fetch($sql))        //循环获取查询记录
{
        echo"标题:".$r['title']."<br>";
}

db_close();                        //关闭MYSQL链接
$empire=null;                        //注消操作类变量
?>

修改后

<?php
require('e/class/connect.php');        //引入数据库配置文件和公共函数文件
require('e/class/db_sql.php');        //引入数据库操作文件
$link=db_connect();                //连接MYSQL
$empire=new mysqlquery();        //声明数据库操作类

$memcache = new Memcache;             //创建一个memcache对象
$memcache->connect('localhost', 11211) or die ("Could not connect"); //连接Memcached服务器

function fetch_memcache($sql,$time=3600){
        global $empire,$memcache,$dbtbpre;
        $key = md5($sql);
        if(!($value =$memcache->get($key))){ //Cache中没有,则从MySQL中查询
         $sql=$empire->query($sql);
         while($r=$empire->fetch($sql)){
          $result[]= $r;
         }
         $value =$result;
         //将Key和Value写入MemCache
         $memcache->set($key,$result,0,time()+$time);
        }
        return $value;
       }

$res=fetch_memcache("select * from {$dbtbpre}ecms_news order by newstime limit 10");        //查询新闻表最新10条记录
while(list($key,$r) = each($res))        //循环获取查询记录
{
        echo"标题:".$r['title']."<br>";
}

db_close();                        //关闭MYSQL链接
$empire=null;                        //注消操作类变量
?>

手机端新建文件

/e/xxx/getHtml.php

<?php
require('../class/connect.php');        //引入数据库配置文件和公共函数文件
require('../class/db_sql.php');        //引入数据库操作文件
require("../class/functions.php");
require("../class/t_functions.php");
require("../data/dbcache/class.php");

require('../class/chtmlfun.php');
require LoadLang('pub/fun.php');

$link=db_connect();                //连接MYSQL
$empire=new mysqlquery();        //声明数据库操作类

$classid=(int)$_GET['classid'];
$id=(int)$_GET['id'];

$r=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id=$id and classid='$classid'");
if($r){
    GetHtml($r['classid'],$r['id'],$r,1);

}

db_close();                        //关闭MYSQL链接
$empire=null;                        //注消操作类变量
?>

pc端修改文件

在自定义函数文件/e/class/userfun.php中添加

function user_ModFun($mid,$isadd,$isq,$classid,$id,$cs){
    ReadFiletext("http://手机端域名/e/xxx/getHtml.php?id=$id&classid=$classid");
}

pc端模型里添加

后台增加信息后处理函数

DELETE FROM tbname WHERE id IN (
    SELECT id from (
        SELECT id FROM tbname  WHERE oldurl in(
            SELECT oldurl FROM tbname  GROUP BY oldurl HAVING count(oldurl) > 1)
            AND id  not IN(SELECT min(id) FROM tbname  GROUP BY oldurl HAVING count(oldurl) > 1)
    ) as t
);