【发布时间】:2015-06-17 16:55:09
【问题描述】:
我有一个包含 30 个 URL 的页面,我需要单击每个 URL 并检查一个元素是否存在。 目前,这意味着:
$('area').each(function(){
$(this).attr('target','_blank');
var _href = $(this).attr("href");
var appID = (window.location.href).split('?')[1];
$(this).attr("href", _href + '?' + appID);
$(this).trigger('click');
});
打开了 30 个新标签,我手动浏览它们。
(所有网址都在同一个域中)
如果有一个具有以下逻辑的爬虫,那就太好了:
$('area').each(function(){
1) get the HREF
2) follow it
3) on that new page:
if($('.element')){
push the $('area') into array1
} else {
push the $('area') into array2
}
});
4) Display array1 in green
Display array2 in red
基本上,我想生成一份报告:
X 抓取的页面有元素 Y
Z 爬取的页面没有元素 Y
我显然坚持让 Javascript/jQuery 在新打开的选项卡中工作。
我找到了 this 、 this 和 this ,但我不完全确定这是否可行。
这可以用 Javascript/jQuery 完成吗?
我只是要求正确的方向,我会自己做这些步骤。
非常感谢
【问题讨论】:
标签: javascript jquery python web-crawler window.open