Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Data retrieving from html text on a webpage Supersedes: <200101771.U1nZRQcY0g@PointedEars.de> Date: Wed, 21 May 2014 14:19:24 +0200 Organization: PointedEars Software (PES) Lines: 71 Message-ID: <1636414.i5R9Cm98m3@PointedEars.de> References: <08bb65e9-25e1-47f0-94bd-c1cb6525375e@googlegroups.com> <537a7de1$0$6653$9b4e6d93@newsspool3.arcor-online.net> <0.fafab0c7006db4827180.20140520004016BST.87wqdhxrq7.fsf@bsb.me.uk> <537b39bd$0$6664$9b4e6d93@newsspool3.arcor-online.net> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1400674766 25177 eJwFwYEBwDAEBMCVBP90HFH2HyF3MB52OEHHYr9RU8A2V6uuTgttmihKxnW1beT8JppAnAcYxxCg (21 May 2014 12:19:26 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 21 May 2014 12:19:26 +0000 (UTC) User-Agent: KNode/4.12.4 Cancel-Key: sha1:MKWZwxYY3ChbwBSLI7x6aAAKgo0= X-User-ID: eJwFwYkBwCAIBLCVqvdgxwEL+4/QRPDyDVqmRrNOjRo6ORd618dw5Mgbxee6IrOjC6MCXXq5E7txkiDxA1YmFTI= 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== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Ben Bacarisse wrote: >> Christoph Michael Becker 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] [1] [2] (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] [4] -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.