如何在标签下的页面上找到某些文字?
我尝试了这个,但它不起作用:
var Link = "http://www.roblox.com/My/Groups.aspx?gid=34039"
function her() {
$.get(Link, function (data) {
if ($(data).find('No One!').length) {
Post()
LoL()
}
})
}
her()
答案 0 :(得分:0)
如果您将数据检索为HTML,则可以在下面进行操作
// below example statement will Find all anchors that has No One! Text
var phraseToFind = "No One!";
//links that contain above phrase example.
var isAnyLinkWithPhraseFound = $(data).find('a:contains('+ phraseToFind +')').length > 0;
您的功能会发生如下变化:
function her() {
var phrase = "No One!";
$.get(Link, function (data) {
if ($(data).find('a:contains('+ phrase +')')
.filter(function(){return $(this).text() === phrase }).length) {
//this filter will give links with exact phrase
Post()
LoL()
}
})
}