Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24308
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Data retrieving from html text on a webpage |
| Date | 2014-05-21 14:19 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1636414.i5R9Cm98m3@PointedEars.de> (permalink) |
| References | <08bb65e9-25e1-47f0-94bd-c1cb6525375e@googlegroups.com> <lldu05$787$1@dont-email.me> <537a7de1$0$6653$9b4e6d93@newsspool3.arcor-online.net> <0.fafab0c7006db4827180.20140520004016BST.87wqdhxrq7.fsf@bsb.me.uk> <537b39bd$0$6664$9b4e6d93@newsspool3.arcor-online.net> |
Christoph Michael Becker wrote:
> Ben Bacarisse wrote:
>> Christoph Michael Becker <cmbecker69@arcor.de> writes:
>>> Denis McMahon wrote:
>>>> On Sun, 18 May 2014 01:18:46 -0700, FAISAL ISMAIL wrote:
>>>>> i am trying to extract html text from a table on the link
>>>>> (http://floodobservatory.colorado.edu/AMSR-E%20Gaging%20Reaches/
>>>> Summary3.htm)
>>>>> the data is in rows and columns. all i want is to extract data for
>>>>> some specific country e.g Pakistan.
>>>>> Kindly help me with the issue.
>>>> By the way, if I was trying to scrape data from a website, I'm not sure
>>>> that javascript would be my first choice language either.
>>> Why not? Are there better alternatives?
>> As always, it depends, but I've had some success using XSLT (which I
>> think refers to eXtensible Stylesheet Language Transformations). Just
>> another option to throw into the pot...
>
> Indeed, using XSLT might be a good idea, but this *can* also be used
> from an ECMAScript implementation.
True. However, it appears to me that it is still proprietary. [0]
The explanation for the abbreviation is correct, which is why XSLT is
probably *not* a good approach here. XSLT can be used to *transform* *XML*-
based markup to other markup or plain text. [1] The original markup here is
neither [2]. It would have to be cleaned-up and converted to XHTML in order
to apply XSLT to it. (I am using XSLT with PHP to convert the FAQ’s XML
documents to HTML. See sig.)
A possibility is XPath, which also has an ECMAScript binding in W3C DOM
Level 3 XPath (or, simply put, there is document.evaluate()). [3] However,
DOM 3 XPath is not interoperable when the document is an HTML document (not
in MSHTML, not even in IE 11). The confusion might have occured because
XPath is the selector language that XSLT is based on.
Another possibility is document.querySelectorAll(), but not here because CSS
selectors cannot select based on element content (as for content, they can
only select based on *attribute* values).
And unless you would want to extract data to the script console, client-side
the SOP issue needs to be solved. But, if the OP can ask the author of this
document (Prof. G. Robert Brakenridge, University of Colorado, Boulder, CO)
for a suitable Access-Control-Allow-Origin header field, then they could
also simply ask them for the data or a suitable filter interface.
So the only possibility would be additional server-side code, which would
beg the questions a) why not use only server-side code in the first place
and b) is it legal to reuse data from this document without asking
permission in the first place? See also [4].
______________
[0] <https://developer.mozilla.org/en-US/docs/XSLTProcessor>
[1] <http://www.w3.org/TR/1999/REC-xslt-19991116>
[2]
<http://validator.w3.org/check?uri=http%3A%2F%2Ffloodobservatory.colorado.edu%2FAMSR-E%2520Gaging%2520Reaches%2FSummary3.htm&charset=%28detect+automatically%29&doctype=HTML+4.01+Transitional&group=0&user-agent=W3C_Validator%2F1.3+http%3A%2F%2Fvalidator.w3.org%2Fservices>
(Validating against HTML 4.01 Transitional will get you 16 errors.
If you validate without overriding the DOCTYPE declaration,
because there is none here the W3C validator will fall back to
XHTML 1.0 Transitional, which will get you 38128 errors after a long
time.)
[3] <http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/ecma-script-binding.html>
[4] <http://floodobservatory.colorado.edu/AMSR-E%20Gaging%20Reaches/>
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
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
Data retrieving from html text on a webpage FAISAL ISMAIL <faesal19@gmail.com> - 2014-05-18 01:18 -0700
Re: Data retrieving from html text on a webpage Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-18 15:41 +0000
Re: Data retrieving from html text on a webpage "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-18 17:41 +0200
Re: Data retrieving from html text on a webpage FAISAL ISMAIL <faesal19@gmail.com> - 2014-05-18 12:52 -0700
Re: Data retrieving from html text on a webpage Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-18 23:29 +0200
Re: Data retrieving from html text on a webpage John Harris <niam@jghnorth.org.uk.invalid> - 2014-05-19 11:04 +0100
Re: Data retrieving from html text on a webpage Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-19 13:11 +0200
Re: Data retrieving from html text on a webpage John Harris <niam@jghnorth.org.uk.invalid> - 2014-05-20 10:43 +0100
Re: Data retrieving from html text on a webpage Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-21 14:34 +0200
Re: Data retrieving from html text on a webpage John Harris <niam@jghnorth.org.uk.invalid> - 2014-05-22 10:42 +0100
Re: Data retrieving from html text on a webpage FAISAL ISMAIL <faesal19@gmail.com> - 2014-05-22 09:07 -0700
Re: Data retrieving from html text on a webpage Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-19 21:44 +0000
Re: Data retrieving from html text on a webpage Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-19 23:55 +0200
Re: Data retrieving from html text on a webpage "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-20 00:04 +0200
Re: Data retrieving from html text on a webpage Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-20 12:59 +0200
Re: Data retrieving from html text on a webpage "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-20 17:13 +0200
Re: Data retrieving from html text on a webpage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-20 00:40 +0100
Re: Data retrieving from html text on a webpage Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-20 13:17 +0200
Re: Data retrieving from html text on a webpage Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-21 14:19 +0200
Re: Data retrieving from html text on a webpage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-21 13:51 +0100
Re: Data retrieving from html text on a webpage Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-21 17:55 +0200
Re: Data retrieving from html text on a webpage Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-20 10:05 +0000
Re: Data retrieving from html text on a webpage Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-20 13:03 +0200
csiph-web