// @name JD
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://item.jd.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict'
// Your code here...
var divObj=document.createElement("input")
divObj.type="button"
divObj.value='获取抓取内容'
divObj.style.marginTop="20px"
divObj.style.marginBottom="20px"
divObj.style.marginLeft="50px"
var first=document.body.firstChild
document.body.insertBefore(divObj,first)
var result={}
divObj.onclick=function(){
//获取价格
if(document.getElementById("jd-price")){
var priceDiv=document.getElementById("jd-price")
var price = priceDiv.innerText
price = price.substr(1)
}else if(document.getElementById("price")){
var pricePri=document.getElementById("price")
var priceDiv=pricePri.firstElementChild
var price = priceDiv.innerText
}else if(document.getElementsByClassName("price")[0]){
var priceClass=document.getElementsByClassName("price")
var priceDiv=priceClass[0]
var price = priceDiv.innerText
}
result.price=price
}
鼠标右键点击然后选择查看源文件,如果你有网页制作方面的基础的话整个网页的源代码都可以看到了如果不懂就把源代码复制到网页制作的源代码区就可以通过所见即所得的方式查看整个网页的编写情况了。希望我的回答对你的问题有帮助