Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #41208

Re: Obtaining the DOM tree for a *.htm file on a local disc?

Path csiph.com!news.swapon.de!news.mb-net.net!open-news-network.org!.POSTED.178.197.201.147!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Obtaining the DOM tree for a *.htm file on a local disc?
Supersedes <12162747.O9o76ZdvQC@PointedEars.de>
Date Tue, 21 Feb 2023 22:15:54 +0100
Organization PointedEars Software (PES)
Lines 41
Message-ID <5657000.DvuYhMxLoT@PointedEars.de> (permalink)
References <7cb3d7c8-74e8-49d2-ba7d-ab6df813f0c1n@googlegroups.com>
Reply-To Thomas 'PointedEars' Lahn <usenet@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
Injection-Info gwaiyur.mb-net.net; posting-host="178.197.201.147"; logging-data="3974651"; mail-complaints-to="abuse@open-news-network.org"
User-Agent KNode/4.14.10
Cancel-Key sha1:E1Jf4+V4d7obqNzGHTBNAAWNzC0=
Cancel-Lock sha1:QRBuKKGBY2B/fZLvCOxyEVtZ8Ko=
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
X-User-ID U2FsdGVkX1+DN3fs1nCrkzFchEqGt/M384ExGQrnFSbZelaa24ZWRA==
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Xref csiph.com comp.lang.javascript:41208

Show key headers only | View raw


John Stockton wrote:

> Is there a readily-available function which can be called from JavaScript
> running in a normal modern browser which, given as an argument the name
> (relative to the current directory, or maybe absolute) of an HTML file,
> will return a reference to the parsed DOM tree of the BODY of the HTML,
> including the Links, Anchors, etc. arrays?

Apparently they have even killed file:// to file:// HTTP requests in/by 
Chromium 108 :-(

| Access to fetch at 'file:///…' from origin 'null' has been blocked by CORS 
| policy: Cross origin requests are only supported for protocol schemes: 
| http, data, isolated-app, chrome-extension, chrome, https, chrome-
| untrusted.

So AFAIK it is only possible now with a local Web server where the target 
file is also a resource accessible via HTTP:

  fetch(httpURI).then(response => {
    response.text().then(response2 => {
      var doc = (new DOMParser()).parseFromString(response2, 'text/html');
        /* Example */
        console.log(doc.images);
    });
  });

(WFM.)

DOMParser is available since the time of Firefox 1 (2006).
If you do not have fetch(), you should write one using XMLHttpRequest.

<https://developer.mozilla.org/en-US/docs/Web/API/DOMParser>
<https://developer.mozilla.org/en-US/docs/Web/API/fetch>
<https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest>
<http://PointedEars.de/es-matrix/#javascript>

-- 
PointedEars
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2
Please do not cc me. /Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-02-16 15:25 -0800
  Re: Obtaining the DOM tree for a *.htm file on a local disc? Dr.Kral@nyc.rr.com - 2023-02-16 19:46 -0500
    Re: Obtaining the DOM tree for a *.htm file on a local disc? Ezimene nimi Teine nimi <yyyyyeeeee00000@writeme.com> - 2023-03-06 03:17 -0800
  Re: Obtaining the DOM tree for a *.htm file on a local disc? Jon Ribbens <jon+usenet@unequivocal.eu> - 2023-02-17 01:06 +0000
  Re: Obtaining the DOM tree for a *.htm file on a local disc? JJ <jj4public@outlook.com> - 2023-02-17 08:34 +0700
  Re: Obtaining the DOM tree for a *.htm file on a local disc? "Jš•’š•žš•–š•¤ š•‚š•šš•£š•œ" <noneya.invalid@gmail.com> - 2023-02-17 15:13 +0000
    Re: Obtaining the DOM tree for a *.htm file on a local disc? K <techfan55555@hotmail.com> - 2023-03-11 01:59 -0800
  Re: Obtaining the DOM tree for a *.htm file on a local disc? Arno Welzel <usenet@arnowelzel.de> - 2023-02-19 00:33 +0100
  Re: Obtaining the DOM tree for a *.htm file on a local disc? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2023-02-21 22:13 +0100
  Re: Obtaining the DOM tree for a *.htm file on a local disc? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2023-02-21 22:15 +0100
    Re: Obtaining the DOM tree for a *.htm file on a local disc? Arno Welzel <usenet@arnowelzel.de> - 2023-03-09 03:06 +0100
  Re: Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-03-04 13:36 -0800
    Re: Obtaining the DOM tree for a *.htm file on a local disc? JJ <jj4public@outlook.com> - 2023-03-05 23:05 +0700
      Re: Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-03-05 15:26 -0800

csiph-web