before_keyword_scraped() hook supported

This commit is contained in:
Nikolai Tschacher
2019-01-29 13:29:24 +01:00
parent c5e3e84e1d
commit 89441070cd
15 changed files with 309 additions and 117 deletions

View File

@ -5,7 +5,7 @@ module.exports = {
scrape_baidu_pup: scrape_baidu_pup,
};
async function scrape_baidu_pup(page, event, context) {
async function scrape_baidu_pup(page, event, context, pluggable) {
await page.goto('https://www.baidu.com/');
try {
@ -21,6 +21,15 @@ async function scrape_baidu_pup(page, event, context) {
keyword = keywords[i];
if (pluggable.before_keyword_scraped) {
await pluggable.before_keyword_scraped({
keyword: keyword,
page: page,
event: event,
context: context,
});
}
try {
const input = await page.$('input[name="wd"]');
// overwrites last text in input