Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24212 > unrolled thread
| Started by | FAISAL ISMAIL <faesal19@gmail.com> |
|---|---|
| First post | 2014-05-18 01:18 -0700 |
| Last post | 2014-05-20 13:03 +0200 |
| Articles | 20 on this page of 23 — 7 participants |
Back to article view | Back to comp.lang.javascript
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
Page 1 of 2 [1] 2 Next page →
| From | FAISAL ISMAIL <faesal19@gmail.com> |
|---|---|
| Date | 2014-05-18 01:18 -0700 |
| Subject | Data retrieving from html text on a webpage |
| Message-ID | <08bb65e9-25e1-47f0-94bd-c1cb6525375e@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-05-18 15:41 +0000 |
| Message-ID | <llakar$do9$1@dont-email.me> |
| In reply to | #24212 |
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. Open the web page select the text you want to capture with the cursor ctrl-c move to the application you want to use the text in position the cursor apporopriately ctrl-v -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-05-18 17:41 +0200 |
| Message-ID | <XnsA331B3F905206eejj99@194.109.133.133> |
| In reply to | #24212 |
FAISAL ISMAIL <faesal19@gmail.com> wrote on 18 mei 2014 in comp.lang.javascript: > 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. I don't see your trying. What did you try, using Javascript? Javascript in a browser or elsewere? Where would you send the result, to a webpage?? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | FAISAL ISMAIL <faesal19@gmail.com> |
|---|---|
| Date | 2014-05-18 12:52 -0700 |
| Message-ID | <e831ed1d-76e0-4729-a14e-5553265e964c@googlegroups.com> |
| In reply to | #24231 |
On Sunday, May 18, 2014 8:41:31 PM UTC+5, Evertjan. wrote: > FAISAL ISMAIL <faesal19@gmail.com> wrote on 18 mei 2014 in > > comp.lang.javascript: > > > > > 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. > > > > I don't see your trying. > > > > What did you try, using Javascript? > > > > Javascript in a browser or elsewere? > > > > Where would you send the result, to a webpage?? > > > > -- > > Evertjan. > > The Netherlands. > > (Please change the x'es to dots in my emailaddress) yeah i am a beginner and i don't know where to start :(
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-05-18 23:29 +0200 |
| Message-ID | <15572699.M38CgDd2lQ@PointedEars.de> |
| In reply to | #24212 |
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.] <http://www.catb.org/~esr/faqs/smart-questions.html> (SCNR) ________ ¹ cf. troglodyte -- 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.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2014-05-19 11:04 +0100 |
| Message-ID | <kcljn9d60qvgrdspb1b114j0f1jrd5ea4p@4ax.com> |
| In reply to | #24258 |
On Sun, 18 May 2014 23:29:09 +0200, Thomas 'PointedEars' Lahn <PointedEars@web.de> 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 ? John
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-05-19 13:11 +0200 |
| Message-ID | <1435438.2RfG4i1VlX@PointedEars.de> |
| In reply to | #24260 |
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.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2014-05-20 10:43 +0100 |
| Message-ID | <2p8mn99faeb8t5l51e8htud3drv57umbqq@4ax.com> |
| In reply to | #24261 |
On Mon, 19 May 2014 13:11:53 +0200, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: >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. <snip> I'll agree to ignore Thomas's spiteful insults if Thomas will agree to stop telling people to obey <http://www.afaik.de/usenet/faq/zitieren/> as he doesn't obey it himself. Incidentally, Usenet is part of Internet; E-mail is part of Internet; E-mail is separate from Usenet; the quoting guidelines apply to E-mail as well. QED John
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-05-21 14:34 +0200 |
| Message-ID | <3168059.zn3XcVQBN8@PointedEars.de> |
| In reply to | #24273 |
John Harris wrote: > Thomas 'PointedEars' Lahn wrote: >> John Harris wrote: >>> 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 in >> include Internet standards, but only in a purely technical sense). Read >> the FAQ. > <snip> > > I'll agree to ignore Thomas's spiteful insults if Thomas will agree to > stop telling people to obey > <http://www.afaik.de/usenet/faq/zitieren/> > as he doesn't obey it himself. You have no clue what you are talking about, and you will not read corrections to your nonsense (but you snip them as that fits your "argument"). This does not bode well for your not being a troll. > Incidentally, Usenet is part of Internet; E-mail is part of Internet; > E-mail is separate from Usenet; the quoting guidelines apply to E-mail > as well. QED Which part of >> It is customary to use rectangular brackets to indicate changes to >> quoted material (in Usenet this stems from its academic background). did you not understand? And which part of my *concession* as to style? Just go away, please. -- 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.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2014-05-22 10:42 +0100 |
| Message-ID | <sihrn9tukp3fuhn6hu1kcuuvdsrtkho4kd@4ax.com> |
| In reply to | #24310 |
On Wed, 21 May 2014 14:34:01 +0200, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: >John Harris wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> John Harris wrote: >>>> 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 in >>> include Internet standards, but only in a purely technical sense). Read >>> the FAQ. >> <snip> >> >> I'll agree to ignore Thomas's spiteful insults if Thomas will agree to >> stop telling people to obey >> <http://www.afaik.de/usenet/faq/zitieren/> >> as he doesn't obey it himself. > >You have no clue what you are talking about, and you will not read >corrections to your nonsense (but you snip them as that fits your >"argument"). This does not bode well for your not being a troll. Thomas is the one who keeps telling people to obey the *.de hierarchy guidelines, in particular Sec 2.8 with 2.9 of <http://www.afaik.de/usenet/faq/zitieren/> which clearly says that what Thomas did is wrong. >> Incidentally, Usenet is part of Internet; E-mail is part of Internet; >> E-mail is separate from Usenet; the quoting guidelines apply to E-mail >> as well. QED > >Which part of > >>> It is customary to use rectangular brackets to indicate changes to >>> quoted material (in Usenet this stems from its academic background). > >did you not understand? And which part of my *concession* as to style? I fail to understand why Thomas didn't use the obvious way to avoid the forgery problem : > Some original text [ Some replacement text] > Some more original text [ Some more replacement text] and so on. >Just go away, please. Bullies always dislike their wrongdoings being pointed out. John
[toc] | [prev] | [next] | [standalone]
| From | FAISAL ISMAIL <faesal19@gmail.com> |
|---|---|
| Date | 2014-05-22 09:07 -0700 |
| Message-ID | <b047d0ab-fd54-4857-89a0-0780803c6d2e@googlegroups.com> |
| In reply to | #24258 |
To be honest, i really had no idea, how to ask question on a forum like this. i am thankful to you and many others who are helping me how to do it, cheers :)
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-05-19 21:44 +0000 |
| Message-ID | <lldu05$787$1@dont-email.me> |
| In reply to | #24212 |
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. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-05-19 23:55 +0200 |
| Message-ID | <537a7de1$0$6653$9b4e6d93@newsspool3.arcor-online.net> |
| In reply to | #24265 |
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? -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-05-20 00:04 +0200 |
| Message-ID | <XnsA333BCD5F7Beejj99@194.109.133.133> |
| In reply to | #24267 |
Christoph Michael Becker <cmbecker69@arcor.de> wrote on 19 mei 2014 in comp.lang.javascript: > 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? If this is about an open website, and the action has to be done repeatedly, my choice would be serverside javascript, and selecting from the input stream with regex, and the page going to my browser just containing the result. On the other hand, using the DOM in the selection process, so needing the browser, is also appealing. Perhaps the choice is what gives you the most joy in programming. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-05-20 12:59 +0200 |
| Message-ID | <537b358a$0$6663$9b4e6d93@newsspool3.arcor-online.net> |
| In reply to | #24268 |
Evertjan. wrote: > Christoph Michael Becker <cmbecker69@arcor.de> wrote on 19 mei 2014 in > comp.lang.javascript: > >> 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? > > If this is about an open website, > and the action has to be done repeatedly, > my choice would be serverside javascript, > and selecting from the input stream with regex, > and the page going to my browser just containing > the result. > > On the other hand, using the DOM in the selection process, > so needing the browser, is also appealing. Using a DOM library from "serverside javascript" doesn't require a browser, though. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-05-20 17:13 +0200 |
| Message-ID | <XnsA333AF3A59503eejj99@194.109.133.133> |
| In reply to | #24276 |
Christoph Michael Becker <cmbecker69@arcor.de> wrote on 20 mei 2014 in comp.lang.javascript: >> On the other hand, using the DOM in the selection process, >> so needing the browser, is also appealing. > > Using a DOM library from "serverside javascript" doesn't require a > browser, though. Indeed, but that applies only where you have such possibility on a server. I have not. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2014-05-20 00:40 +0100 |
| Message-ID | <0.fafab0c7006db4827180.20140520004016BST.87wqdhxrq7.fsf@bsb.me.uk> |
| In reply to | #24267 |
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... -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-05-20 13:17 +0200 |
| Message-ID | <537b39bd$0$6664$9b4e6d93@newsspool3.arcor-online.net> |
| In reply to | #24269 |
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. Anyway, my question was more a rhetoric one. IMHO it doesn't make much of a difference which language one is using for this task, as long as there are appropriate libraries available. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-05-21 14:19 +0200 |
| Message-ID | <1636414.i5R9Cm98m3@PointedEars.de> |
| In reply to | #24278 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2014-05-21 13:51 +0100 |
| Message-ID | <0.7e3f6ab9ff9c0c2b3551.20140521135136BST.87oayruwfb.fsf@bsb.me.uk> |
| In reply to | #24308 |
Thomas 'PointedEars' Lahn <PointedEars@web.de> writes: > 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] As it happens, I was replying to the "better alternatives to javascript" part. I wasn't suggesting a specific JS library. The tool I'd found useful was the xsltproc command, built with libxslt which seems to be part of GNOME. > 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 used xsltproc on some pretty dreadful HTML texts. The command has a flag to signal that the input is HTML, but I have no idea what it really does. It may throw the hole thing into some standards-negating black hole of arbitrary behaviour, or it might be reasonably well-defined somewhere. The point I wanted to make was that I found it useful. I had a job to get done, which was scraping data from some very badly written HTML pages, and I found xlstproc did the job very well. I should probably have been more specific about the tool I used, because XSLT might, in other implementations, be unsuitable. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web