使用 Apify,如何提取依赖于模态 window 输入的数据?
Using Apify, how to extract data that is dependent on a modal window input?
我有兴趣抓取具有模式 window 到 select 位置的网站。网站数据取决于 select 在模式 window 上编辑的位置。
如何显示模态 window 和 select 我有兴趣抓取的位置?
我熟悉Apify,我打算使用interceptRequest()回调函数来显示模态window和select,但我不太熟悉如何做.
编辑:为清楚起见添加图片
通常,模态框在scraping/automation中并没有那么特殊。您可以等待模式的选择器加载,然后您可以单击关闭模式或执行任何其他操作。
所以我检查了工作流程,没有什么特别的。我不会包括整个代码。您可以在 Apify SDK and docs of Puppeteer 上找到详细的教程,您可以在线找到它的所有功能。
因此,一旦您进入 handlePageFunction
原始演员或 Puppeteer Scraper,您只需单击 Ver Precio 按钮,等待模式打开,然后填写输入和提交。
await page.click('.verprecio');
await page.waitForSelector('#frmBuscarSucursal2'); // Selector of the modal body
// Alternatively, if this will cause problems, you can just use plain waitFor
// await page.waitFor(5000) // waits 5 secs
// Now we select region
await page.select('#cmbRegiones2', '11'); // Each region has a number value
await page.select('#cmbMunicipio2', '901'); // The same for municipio
// And we submit by clicking on Buscar
await page.click('#btn-modal-buscar2');
如果您想使用 Web Scraper 来简单起见,您也可以使用纯 javascript 来管理它,但它通常不如使用 Puppeteer 函数可靠。
我有兴趣抓取具有模式 window 到 select 位置的网站。网站数据取决于 select 在模式 window 上编辑的位置。
如何显示模态 window 和 select 我有兴趣抓取的位置?
我熟悉Apify,我打算使用interceptRequest()回调函数来显示模态window和select,但我不太熟悉如何做.
编辑:为清楚起见添加图片
通常,模态框在scraping/automation中并没有那么特殊。您可以等待模式的选择器加载,然后您可以单击关闭模式或执行任何其他操作。
所以我检查了工作流程,没有什么特别的。我不会包括整个代码。您可以在 Apify SDK and docs of Puppeteer 上找到详细的教程,您可以在线找到它的所有功能。
因此,一旦您进入 handlePageFunction
原始演员或 Puppeteer Scraper,您只需单击 Ver Precio 按钮,等待模式打开,然后填写输入和提交。
await page.click('.verprecio');
await page.waitForSelector('#frmBuscarSucursal2'); // Selector of the modal body
// Alternatively, if this will cause problems, you can just use plain waitFor
// await page.waitFor(5000) // waits 5 secs
// Now we select region
await page.select('#cmbRegiones2', '11'); // Each region has a number value
await page.select('#cmbMunicipio2', '901'); // The same for municipio
// And we submit by clicking on Buscar
await page.click('#btn-modal-buscar2');
如果您想使用 Web Scraper 来简单起见,您也可以使用纯 javascript 来管理它,但它通常不如使用 Puppeteer 函数可靠。