// ==UserScript== // @name pdd商品详情页采集 // @namespace http://tampermonkey.net/ // @version 2024-01-06 // @description try to take over the world! // @author You // @match https://mobile.yangkeduo.com/goods.html?goods_id=* // @icon https://www.google.com/s2/favicons?sz=64&domain=yangkeduo.com // @require http://cdn.bootcss.com/jquery/1.11.2/jquery.js // @require https://scriptcat.org/lib/513/2.0.0/ElementGetter.js // @grant GM_xmlhttpRequest // @license MIT // ==/UserScript== function sleep(number){ var now = new Date(); var exitTime = now.getTime() + number * 1000; while (true) { now = new Date(); if(now.getTime() > exitTime) return } } function price_trans(old_price) { let new_price = ""; // 新字符串变量 // 获取倒数第二位和倒数第三位之前的子字符串 new_price += old_price.substring(0, old_price.length - 2); // 在倒数第二位后面添加小数点 new_price += "."; // 将倒数第三位到最后的部分连接起来 new_price += old_price.slice(-2); return new_price } // 获取分类 function get_category(){ elmGetter.selector($); var content elmGetter.get([ 'ul.m-breadcrumb-list li.active a' ]).then(([category]) => { content = category.text() console.log('获取到了分类') console.log(typeof content) return content }) return content } (function() { 'use strict'; var start = new Date().getTime(); var monkey_url = 'http://127.0.0.1:8883/itemList'; // 单独购买按钮-点击 document.querySelector('._18tsD01C ._1rkc8zzD').click() //尺码-点击 elmGetter.get(['div._3P3M8kC- div:nth-child(3)' ]).then(([category]) => { category.click() // 在输入框填写数字 elmGetter.get(['._2Dfevmvi' ]).then(([stock_num]) => { stock_num.value = 9999 }) // zz = document.querySelector('._2Dfevmvi') // zz.value = 9999 // 减号-点击 elmGetter.get(['._2BM66E_I' ]).then(([minus_button]) => { minus_button.click() }) // document.querySelector('._2BM66E_I').click() // 加号-点击 elmGetter.get(['.fFnfVnqP' ]).then(([plus_button]) => { plus_button.click() }) // document.querySelector('.fFnfVnqP').click() }) // document.querySelector('._3P3M8kC- div:nth-child(3)').click() })();