油猴采集aliexpress
脚本:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.aliexpress.com/*
// @grant GM_xmlhttpRequest
// @grant GM_download
// @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// @connect *
// ==/UserScript==
/* jshint -W097 */
(function() {
setTimeout(function(){
//alert(2222);
var title = $(".product-title-text");
var titlStr = "";
var priceStr = "";
if (title.length==1) {
titlStr = title.html();
titlStr = encodeURIComponent(titlStr);
}
if ($(".product-price-original .product-price-value").length==1) {
priceStr = $(".product-price-original .product-price-value").html();
priceStr = encodeURIComponent(priceStr);
}
var imgs="";
var i = 0;
$(".images-view-wrap .images-view-item img").each(function(){
i++;
var imgStr = $(this).attr("src");
imgs += "&img"+i+"="+encodeURIComponent(imgStr);
});
var descript = $(".product-overview").prop("outerHTML");
console.log(descript);
descript = encodeURIComponent(descript);
// alert(descript);
var url = "http://fecshop.appfront.fancyecommerce.com/catalog/category/test";
url += "?titlStr="+titlStr;
url += "&priceStr="+priceStr;
url += imgs;
url += "&descript=" + descript;
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(response) {
}
});
} ,5000);
})();
php action方法
public function actionTest()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$myfile = fopen("/www/web/develop/fecshop/appfront/runtime/fecshop_logs/22.txt", "w") or die("Unable to open file!");
$descript =$get['descript'];
fwrite($myfile, $descript);
fclose($myfile);
//\Yii::info(json_encode($get), 'fecshop_debug');
// \Yii::info(json_encode($post), 'fecshop_debug');
echo 1;exit;
}