拼多多采集

pdd采集

  1. // ==UserScript==
  2. // @name 拼多多采集
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-12-23
  5. // @description pdd采集
  6. // @author bzy
  7. // @match https://mobile.yangkeduo.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=microsoft.com
  9. // @run-at document-end
  10. // @grant GM_xmlhttpRequest
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function sendRequest2(method, url, data = null, callback = null, headers = {}) {
  18. // 创建 XMLHttpRequest 对象
  19. const xhr = new XMLHttpRequest();
  20.  
  21. // 配置请求
  22. xhr.open(method, url, true);
  23.  
  24. // 设置请求头(可以根据需要自定义)
  25. for (const key in headers) {
  26. xhr.setRequestHeader(key, headers[key]);
  27. }
  28.  
  29. // 设置请求完成后的回调函数
  30. console.log(url)
  31. xhr.onload = function() {
  32. if (xhr.status >= 200 && xhr.status < 300) {
  33. console.log("已上传")
  34. // 请求成功
  35. if (callback) callback(null, xhr.responseText);
  36. } else {
  37. console.log("失败")
  38. // 请求失败
  39. if (callback) callback(new Error(`Request failed with status ${xhr.status}`));
  40. }
  41. };
  42.  
  43. // 处理请求错误
  44. xhr.onerror = function() {
  45. if (callback) callback(new Error('Network error'));
  46. };
  47.  
  48. // 发送请求(如果有请求体,则发送数据)
  49. xhr.send(data);
  50. }
  51.  
  52. let url = window.location.href
  53. // unsafeWindow.alert("找到商品")
  54. if (url.includes('mobile.yangkeduo.com/goods2.html?goods_id')) {
  55. try {
  56. const urlParams = new URLSearchParams(window.location.search);
  57. const goodsId = urlParams.get("goods_id");
  58. const userId = urlParams.get("user_id");
  59. let pageHTML = document.documentElement.outerHTML
  60. const regex = /window\.rawData\s*=\s*(.*?);/s;
  61. const match = pageHTML.match(regex);
  62. // const rawDataValue = match[1].trim();
  63. // console.log("window.rawData 的值为:", rawDataValue);
  64. // alert(match[1])
  65. if (match && match[1]) {
  66. // unsafeWindow.fetch ("http://45.136.13.81:5002/up", {"body": "{'123': '456'}"})
  67. // alert("有商品")
  68. const rawDataValue = match[1].trim();
  69. if (rawDataValue.includes("商品已售罄")) {
  70. return
  71. }
  72. url = "http://45.136.13.81:5002/up"
  73. GM_xmlhttpRequest({
  74. "url": url,
  75. "data": JSON.stringify({
  76. "goods_id": goodsId,
  77. "goods_detail":rawDataValue,
  78. "use":"005"
  79. }),
  80. "method": "POST",
  81. "headers": {"Content-Type":"application/json"},
  82. "onload": (res) => {
  83. console.log(JSON.stringify(res))
  84. }
  85. })
  86.  
  87.  
  88. sendRequest2("GET", "https://pddcj.https7.com/api/v1/other/achieve?goods_id=" + goodsId + "&status=1&user_id=" + userId )
  89. } else {
  90. console.log("没有找到");
  91. }
  92. } catch (error) {
  93. alert("出错" + error)
  94. }
  95.  
  96. }
  97. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址