所以我想从网页上获取一个链接,所以我决定获取源代码->搜索该链接并将该链接放入变量中。
但是我找不到在获取结果中进行搜索的方法
我试图在控制台中获取内容并在其中搜索,但似乎无法实现
const proxyurl = "https://cors-anywhere.herokuapp.com/";
const url = "https://example.com";
fetch(proxyurl + url)
.then(response => response.text())
.then(contents => console.log(contents))
.catch(() => console.log("Can’t access " + url + " response. Blocked by browser?"))
编辑:
因此,为了澄清我使用的是node-fetch,而const网址位于实际代码中,而不是example.com
我从网页(外部)获得了完整的源代码,并在控制台的此示例中显示了它们。但是我想在源代码中搜索特定的链接,这就是我的问题。
链接到cors-wherewhere文档:https://github.com/Rob--W/cors-anywhere/#documentation