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