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


Groups > comp.lang.javascript > #24261

Re: Data retrieving from html text on a webpage

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Data retrieving from html text on a webpage
Date 2014-05-19 13:11 +0200
Organization PointedEars Software (PES)
Message-ID <1435438.2RfG4i1VlX@PointedEars.de> (permalink)
References <08bb65e9-25e1-47f0-94bd-c1cb6525375e@googlegroups.com> <15572699.M38CgDd2lQ@PointedEars.de> <kcljn9d60qvgrdspb1b114j0f1jrd5ea4p@4ax.com>

Show all headers | View raw


John Harris wrote:

> Thomas 'PointedEars' Lahn wrote:
>> FAISAL ISMAIL wrote [translated]:
>>> i am [a Googlodyte¹] trying to [steal copyrighted information] from a
>>> table on the [website] (http://floodobservatory.colorado.edu/AMSR-E%20Gaging%20Reaches/Summary3.htm)
>>> the data is in rows and columns.  [I only want to steal] data for some
>>> specific country e.g Pakistan [in order to present it later as if it was
>>> my original research].
>>> [I want you to give me the code for free and be an accessor to this
>>> [crime without any questions asked because I think you are stupid enough
>>> to have a big enough helper complex to do just that.  Otherwise I have
>>> no clue what I am doing, and I cannot be bothered to search the Net, to
>>> learn and try something.]
>   <snip>
> 
> Why does Thomas use the symbol '>', meaning a direct literal unchanged
> copy of another's text, when he is supplying text written by him ?
> 
> Could it be that Internet rules don't apply to Thomas ?
                                                       ^
Could it be that you are still either only trolling here or still have no 
clue where you are reading and posting to?  This is *Usenet*, _not_ the 
Internet.  If any rules apply here, they are *Usenet* rules (which include 
Internet standards, but only in a purely technical sense).  Read the FAQ.

I concede that the style of my posting was in a non-hacker sense 
inappropriate; however, its formatting certainly was not (by contrast to 
that of the OP, due to the buggy interface and cluelessness):

It is customary to use rectangular brackets to indicate changes to quoted 
material (in Usenet this stems from its academic background).

I gave an additional hint as to what I found wrong with the OP and how to 
fix it, and I said sorry in advance for my style, though (which you snipped 
both, probably with purpose).

Anyhow, here is a more appropriate answer:

The rows of a table (section), and the cells of each row, are represented in 
the DOM as objects implementing the NodeList or HTMLCollection 
interface. [1]  (Therefore,) they can be converted to an Array of Arrays by 
calling the Array.prototype.map() method on them, respectively. [2]

In turn, elements of an Array instance can be filtered by calling the 
filter() method that it inherits from the built-in Array prototype 
(implementations of ECMAScript Edition 5 and later only, respectively) [3]:

  var filtered_data = [].map.call(
    table.tBodies[0].rows,
    function (row) {
      return [].map.call(
        row.cells,
        function (cell) {
          /* you can also do type conversion of cell data here */
          return …;
        }
      );
    }
  ).filter(
    function (row) {
      return …;
    }
  );

(Written less compact here for better understanding.  For increased 
efficiency, the value of [].map can be stored in a variable if needed 
repeatedly.)

Instead of calling these methods, one may also build arrays from rows and 
cells in C-style “for” loops.

It could be also more efficient to reverse the order: filter first, map 
second (because then you only need to map the data of the remaining rows).

___________
[1] <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement.tBodies> pp.
[2] <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map> pp.
[3] <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter> pp.

-- 
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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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