function yunfeng(address,callback) {
var yun = '';
var url = "https://etherscan.io/tokenholdingsnew.aspx/GetAssetDetails";
var params = { "dataTableModel": { "draw": 2, "columns": [{ "data": "TokenName", "name": "", "searchable": true, "orderable": true, "search": { "value": "", "regex": false } }, { "data": "Symbol", "name": "", "searchable": true, "orderable": false, "search": { "value": "", "regex": false } }, { "data": "ContractAddress", "name": "", "searchable": true, "orderable": false, "search": { "value": "", "regex": false } }, { "data": "Balance", "name": "", "searchable": true, "orderable": true, "search": { "value": "", "regex": false } }, { "data": "Price", "name": "", "searchable": true, "orderable": true, "search": { "value": "", "regex": false } }, { "data": "Change24H", "name": "", "searchable": true, "orderable": false, "search": { "value": "", "regex": false } }, { "data": "Value", "name": "", "searchable": true, "orderable": true, "search": { "value": "", "regex": false } }, { "data": "More", "name": "", "searchable": true, "orderable": false, "search": { "value": "", "regex": false } }], "order": [{ "column": 6, "dir": "desc" }], "start": 0, "length": 10000, "search": { "value": "", "regex": false } }, "model": { "address": address, "hideZeroAssets": false, "filteredContract": "", "showEthPrice": false } };
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
yun = xhr.responseText;
callback(yun)
} else {
console.error(xhr.statusText);
}
}
};
xhr.onerror = function (e) {
console.error(xhr.statusText);
};
xhr.send(JSON.stringify(params));
//return xhr.responseText//不能return,ajax未返回
}
var add = '0x05e793ce0c6027323ac150f6d45c2344d28b6019'
yunfeng(add, function (yun) {
console.log(yun)
})
这段js代码,我在浏览器的控制台是可以获取到的值,但是selenium得到的就是NOne
安装
直接到项目的github上下载打好的压缩包即可:https://github.com/lightbody/browsermob-proxy/releases ,支持Linux和Windows。
安装对应的python包:
pip install browsermob-proxy
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!