特定网页中的Javascript搜索字符串

时间:2018-07-04 13:20:34

标签: javascript search find web-crawler

我在Construct 2中制作了小型游戏,我需要一些关于javascript的帮助。我需要在特定的内部页面中搜索某些内容。

我需要搜索我的发布ID是否在我的游戏所在的每个域的ads.txt中。问题在于我无法弄清楚如何爬网到其他内部页面,因为使用“文档”并没有帮助我。

var id='2314121'; //my id
var found = document.documentElement.innerHTML.indexOf(id); //it's searching my id in the HTML code
if(found >= 0) //it will return -1 if it's not there, and position if's there
{
   alert('Found it at position: '+found);
}

问题是这将仅在当前页面中搜索,而我需要在特定页面中搜索。我需要在“ www.domainexample.com/ads.txt”中进行搜索。

我找到了如何使用“ window.location.host”来判断我在哪个站点上的信息,但是我被困在这里。我无法从索引爬到ads.txt。

有人知道怎么做吗?

谢谢! :)

0 个答案:

没有答案
相关问题