【发布时间】:2010-05-07 06:56:34
【问题描述】:
在 jQuery 中你可以这样做:
$("a[href$='.img']").each(function(index) {
alert($(this).attr('href'));
}
我想编写一个 jQuery 函数,它从网站抓取 x 级别并收集所有 href 到 gif 图像。
所以当我使用 get 函数检索另一个页面时,
$.get(href, function(data) {
});
我希望能够做类似的事情
data.$("a[href$='.img']").each(function(index) {
});
这可能吗?
...更新...
多亏了答案,我才能解决这个问题。
function FetchPage(href) {
$.ajax({
url: href,
async: false,
cache: false,
success: function(html){
$("#__tmp__").append("<page><name>" + href + "</name><content>" + html + "</content></page>");
}
});
}
有关如何使用它的示例,请参阅this zip file。
【问题讨论】:
标签: jquery web variables hyperlink web-crawler