MCPcopy Create free account
hub / github.com/deta/surf / fetchRemoteHTML

Method fetchRemoteHTML

packages/web-parser/src/extractors/metadata.ts:13–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 }
12
13 private async fetchRemoteHTML() {
14 const response = await fetch(this.url.href, {
15 method: 'GET',
16 headers: {
17 'User-Agent':
18 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
19 'Content-Type': 'text/html'
20 }
21 })
22
23 if (!response.ok) {
24 throw new Error('Failed to fetch the page')
25 }
26
27 return response.text()
28 }
29
30 private createDocumentFromHTML(html: string) {
31 const parser = new DOMParser()

Callers 1

extractRemoteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected