我的语法有什么问题?
它抛出一个错误:
Scraping failed Error: Evaluation failed: ReferenceError: getLogo is not defined
代码片段:
const universityAtt = await page.evaluate(() => {
// Getting total number of universities
let totalUniversities = document.querySelector('ul.universities-search-result').childElementCount
for (i = 0; i < totalUniversities; i++) {
getLogo += document.querySelectorAll('.profile_lead > .dp > img.logo-90x90')[i].src;
universityURL += document.querySelectorAll('a.profile.adv, a.profile.basic')[i].href;
let x = [getLogo, universityURL];
};
return x;
});
编辑 (1) 当我声明 getLogo 和 universityURL 变量时,
const universityAtt = await page.evaluate(() => {
// Getting total number of universities
let totalUniversities = document.querySelector('ul.universities-search-result').childElementCount
for (i = 0; i < totalUniversities; i++) {
let getLogo += document.querySelectorAll('.profile_lead > .dp > img.logo-90x90')[i].src;
let universityURL += document.querySelectorAll('a.profile.adv, a.profile.basic')[i].href;
let x = [getLogo, universityURL];
};
return x;
});
我收到此错误:
SyntaxError: Unexpected token '+='
at wrapSafe (internal/modules/cjs/loader.js:1116:16)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
一只甜甜圈
隔江千里
跃然一笑
慕尼黑8549860
相关分类