|
|
@ -8,7 +8,6 @@ class Bilibili extends HeroBot { |
|
|
|
async scrap(url) { |
|
|
|
async scrap(url) { |
|
|
|
let data = {url: url, done: false}; |
|
|
|
let data = {url: url, done: false}; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
let options = { |
|
|
|
let options = { |
|
|
|
userAgent: configs.userAgent, |
|
|
|
userAgent: configs.userAgent, |
|
|
|
viewport: configs.viewport |
|
|
|
viewport: configs.viewport |
|
|
@ -18,12 +17,18 @@ class Bilibili extends HeroBot { |
|
|
|
options.connectionToCore = this.heroServer; |
|
|
|
options.connectionToCore = this.heroServer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
const profile = await this.init('bilibili'); |
|
|
|
const profile = await this.init('bilibili'); |
|
|
|
if (profile) { |
|
|
|
if (profile) { |
|
|
|
options.userProfile = profile; |
|
|
|
options.userProfile = profile; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}catch(err) { |
|
|
|
|
|
|
|
console.error("Error got when init Bilibili bot", err); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const hero = new Hero(options); |
|
|
|
const hero = new Hero(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
hero.use(ClientLogPlugin); //开启log
|
|
|
|
hero.use(ClientLogPlugin); //开启log
|
|
|
|
await hero.goto(url, configs.heroBotOptions); |
|
|
|
await hero.goto(url, configs.heroBotOptions); |
|
|
|
|
|
|
|
|
|
|
@ -79,6 +84,7 @@ class Bilibili extends HeroBot { |
|
|
|
data.done = true; |
|
|
|
data.done = true; |
|
|
|
}catch(error) { |
|
|
|
}catch(error) { |
|
|
|
console.error("Error got when request %s via hero: %s", url, error); |
|
|
|
console.error("Error got when request %s via hero: %s", url, error); |
|
|
|
|
|
|
|
await hero.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
return data; |
|
|
|