PinPHP后台批量采集的功能二次开发修改实现
使用PinPHP有一段时间了,利用PinPHP在Sae上搭了个环境,运营一个月左右的《时尚美汇》,所以最近也一直在研究这套程序,顺便做些二次开发,加入些自己的想法。例如之前写过的博文:加入人人网帐号登录(淘宝登录其实也做了,只是在淘宝应用中心上用)、修改PinPHP采集。
好吧,今天来说说关于PinPHP后台批量采集的功能二次开发修改实现,本人一开始接解pinphp,使用的是2.1测试版,
到现在官方已经发布了2.2版,但遗憾的是,大家一值期待的批量采集功能并没有如愿发布,所以本人自己尝试去修改修改,
其实程序早在半个月前就写好了,只是自己在用,一方面工作有点忙,另一方面自己测试一段时间,顺便完善一下。
实现原现很简单,主要是修改采集界面,加了几个checkbox,用于传递要采集的id、关键字等。
1、修改:admin\Tpl\default\items_collect\collect.html页面,28行左右。
Copy to Clipboard引用的内容:[www.bkjia.com]官方应该是有尝试去做批量采集,因为此页面上有关于批量采集的代码未完成,只是注释了。
2、然后在\admin\Lib\Action\items_collectAction.class.php上增加了一个函数,以及略修改原采集函数
Copy to Clipboard引用的内容:[www.bkjia.com] function ajaxCollect(){set_time_limit(0);
$subname=$_REQUEST['subname'];
$arrUrls=array();
foreach($_REQUEST['cate'] as $k=>$v){
if(!empty($subname[$k])){
$arrUrls[]='http://mmlike.sinaapp.com/mlike_admin.php?a=taobao_collect_jump&m=items_collect&pages=1&cate_id='.$v.'&keywords='.$subname[$k];
}
}
$this->assign('url',json_encode($arrUrls));
$this->display('ajaxCollect');
}
这一句有一些信息要注意一下
Copy to Clipboard引用的内容:[www.bkjia.com] $arrUrls[]='http://mmlike.sinaapp.com/mlike_admin.php?a=taobao_collect_jump&m=items_collect&pages=1&cate_id='.$v.'&keywords='.$subname[$k];page=1是采集一页,每页40个商品,如果需要一次采集更多商品,可自行修改,但不建议填太大的值,一方面采集时间长,另一方面,淘宝api请求可能会太频繁。
修改public function collect()函数,前半部分的if改成
Copy to Clipboard引用的内容:[www.bkjia.com] if(isset($_REQUEST['dosubmit'])){/******批量采集*******/
$cate=implode(',',$_REQUEST['cate']);
$this->ajaxCollect();
//header("location:".U('items_collect/taobao_batch_collect_jump?act=batch&cate='.$cate));
exit;
/******批量采集*******/
}
3、在模板里增加一个,\admin\Tpl\default\items_collect\ajaxCollect.html
Copy to Clipboard引用的内容:[www.bkjia.com]了解php和js的朋友应该看懂,将组装好的采集url,以json形式放在js里,利用setInterval定时器去定时执行ajax请求,遍历所有的url
直到完成。一开始用setInterval而不是直接for遍历是担心分类多时,太频繁请求淘宝api会导致部份采集不成功。
上面的ajax使用异步请求,之前尝试使用同步去获取,是为了方便捕获到那个采集成功,哪个不成功,以便手动去采集,
测试了一段时间,虽然效果是达到了,但由于分类太多一次采集的时候,浏览器会卡,而已采集总时间也变长漫长。现还是使用
异步,不卡,缩短采集时间,虽然也可以实现失败捕足,但要修改更多的代码,这个有时间有研究。现在的效果如下
用%比显示进度,最后会显示完成度和有多少个失败,至于失败的再采集一次,又或者自己去检查哪个未采集手动采集。
这个修改后,原采集功能也可正常使用。
重申一下,本人使用的是pinphp2.1测试版,其他版本若要修改,可作为参考,以下是修改文件的打包,不建议直接覆盖,最好
对比一下代码,如要覆盖,请先备份原文件,以便恢复。
点击下载:pinphp批量采集
教程来源:http://meego123.net/?post=140

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



1. First open DingTalk. 2. Open the group chat and click the three dots in the upper right corner. 3. Find my nickname in this group. 4. Click to enter to modify and save.

Both vivox100s and x100 mobile phones are representative models in vivo's mobile phone product line. They respectively represent vivo's high-end technology level in different time periods. Therefore, the two mobile phones have certain differences in design, performance and functions. This article will conduct a detailed comparison between these two mobile phones in terms of performance comparison and function analysis to help consumers better choose the mobile phone that suits them. First, let’s look at the performance comparison between vivox100s and x100. vivox100s is equipped with the latest

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

Douyin Blue V certification is the official certification of a company or brand on the Douyin platform, which helps enhance brand image and credibility. With the adjustment of corporate development strategy or the update of brand image, the company may want to change the name of Douyin Blue V certification. So, can Douyin Blue V change its name? The answer is yes. This article will introduce in detail the steps to modify the name of the enterprise Douyin Blue V account. 1. Can Douyin Blue V change its name? You can change the name of Douyin Blue V account. According to Douyin’s official regulations, corporate Blue V certified accounts can apply to change their account names after meeting certain conditions. Generally speaking, enterprises need to provide relevant supporting materials, such as business licenses, organization code certificates, etc., to prove the legality and necessity of changing the name. 2. What are the steps to modify the name of corporate Douyin Blue V account?

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.
