我试图从一系列HTML页面中抓取数据。 对于访问,有一些参数包含查询。 这些参数保存到json中。和儿子这样写的。
[
{"NM":"bla", "Code":"a12312"},
{"NM":"blabla", "Code":"a11231"},
{"NM":"dog", "Code":"b12311"},
...]
,下一个是parsing1.js的代码
var jsdom = require("jsdom");
var schCD = require('./ggElemCD.json');
for(i in schCD){
jsdom.env("http://www.~~skipped~~&HG_CD="+schCD[i].HG_CD+"~~skipped~~", ["http://code.jquery.com/jquery.js"],
function(errors, window){
var tObj= window.$('.TableType1 tbody tr:last td');
console.log( "Name : "+schCD[i].HG_NM);
console.log( "Code : "+schCD[i].HG_CD);
var completeObj = {
"HG_name": schCD[i],
"HG_CD": schCD[i].HG_CD,
"G1st_m" : tObj.get(0).innerHTML,
"G1st_f" : tObj.get(1).innerHTML,
"G2nd_m" : tObj.get(3).innerHTML,
"G2nd_f" : tObj.get(4).innerHTML,
"G3rd_m" : tObj.get(6).innerHTML,
"G3rd_f" : tObj.get(7).innerHTML,
"G4th_m" : tObj.get(9).innerHTML,
"G4th_f" : tObj.get(10).innerHTML,
"G5th_m" : tObj.get(12).innerHTML,
"G5th_f" : tObj.get(13).innerHTML,
"G6th_m" : tObj.get(15).innerHTML,
"G6th_f" : tObj.get(16).innerHTML,
"sp_m" : tObj.get(18).innerHTML,
"sp_f" : tObj.get(19).innerHTML
}
console.log("value1 : "+completeObj.G1st_m);
console.log("value2 : "+completeObj.G1st_f);
});
}
如果删除了for-syntax并且手动将HG_CD放入此代码,则它可以正常工作。但是,当我插入for-syntax时,节点打印出错误消息。
/Users/Snark/Dev/parsing/parsing1.js:8
var tObj= window.$('.TableType1 tbody tr:last td');
^
TypeError: Cannot read property '$' of undefined
at Object.done (/Users/Snark/Dev/parsing/parsing1.js:8:18)
at reportInitError (/Users/Snark/node_modules/jsdom/lib/jsdom.js:384:12)
at /Users/Snark/node_modules/jsdom/lib/jsdom.js:220:9
at Request._callback (/Users/Snark/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:159:64)
at self.callback (/Users/Snark/node_modules/jsdom/node_modules/request/request.js:198:22)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at Request.onRequestError (/Users/Snark/node_modules/jsdom/node_modules/request/request.js:820:8)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
答案 0 :(得分:0)
您的问题与并发请求有关,因为您似乎拥有高数量的请求,您应该在向同一服务器发出另一个请求之前等待您的请求完成。以下是如何完成它using the async library:
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run wshShell.ExpandEnvironmentStrings( "%SystemRoot%\system32\cmd.exe /c rd """ & fullTempName & """" ), 0