Reading and interpreting data from web page

R

royg567

Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.
 
M

Martie

Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.

Something like this:

javascript:eek:utText='';for(i=0;i<document.links.length;i++)
{if(outText.in
dexOf(document.links)==-1){outText+='<tr><td><a
href='+document.links+'>'+document.links+'</a></td></
tr>';}};if(ou
tText!='')
{imgWindow=window.open('','linkWin','');imgWindow.document.wri
te('<table border=1
cellpadding=10><tr><th>URL</th></tr>'+outText+'</
table>');imgWindow.docu
ment.close();}else{alert('No Links!')}

and/or:

javascript:eek:utText='';for(i=0;i<document.images.length;i++)
{with(documen
t.images){if(outText.indexOf(src)==-1){outText+='<tr><td><img
src='+src+'></td><td>'+height+'</td><td>'+width+'</td><td>'+src+'</
td></
tr>';}}};if(outText!='')
{imgWindow=window.open('','imgWin','');imgWindow
..document.write('<table border=1
cellpadding=10><tr><th>Image</th><th>height</th><th>Width</th><th>URL</
t
h></tr>'+outText+'</table>');imgWindow.document.close();}
else{alert('No
Images!')}

??

Greetings
 
M

Martie

Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.

Open your requested page in the browser.
Then paste 1 of these javascript lines i the adress-bar and press
[Enter].
 
T

Thomas 'PointedEars' Lahn

royg567 said:
Can anyone advise how to read data from a web page using javascript ?

No said:
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.

Google for "document.links" and "XMLHttpRequest". And read the
<http://jibbering.com/faq/>.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Martie said:
Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.

Something like this:

javascript:eek:utText='';for(i=0;i<document.links.length;i++)
{if(outText.in
dexOf(document.links)==-1){outText+='<tr><td><a
href='+document.links+'>'+document.links+'</a></td></
tr>';}};if(ou
tText!='')
{imgWindow=window.open('','linkWin','');imgWindow.document.wri
te('<table border=1
cellpadding=10><tr><th>URL</th></tr>'+outText+'</
table>');imgWindow.docu
ment.close();}else{alert('No Links!')}

and/or:

javascript:eek:utText='';for(i=0;i<document.images.length;i++)
{with(documen
t.images){if(outText.indexOf(src)==-1){outText+='<tr><td><img
src='+src+'></td><td>'+height+'</td><td>'+width+'</td><td>'+src+'</
td></
tr>';}}};if(outText!='')
{imgWindow=window.open('','imgWin','');imgWindow
.document.write('<table border=1
cellpadding=10><tr><th>Image</th><th>height</th><th>Width</th><th>URL</
t
h></tr>'+outText+'</table>');imgWindow.document.close();}
else{alert('No
Images!')}

??


No. Please don't.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Martie said:
Open your requested page in the browser.

So that would not include the most recent version of Konqueror …

[x] You only know Microsoft Internet Explorer.
Then paste 1 of these javascript lines i the adress-bar and press
[Enter].

No, don't.


PointedEars
 
M

Martie

Open your requested page in the browser.

So that would not include the most recent version of Konqueror …

[x] You only know Microsoft Internet Explorer.
I'm not using Micro$oft Internet Exploder, i'm using Safari (version
5.0.3) as the browser (it works here).
I't is a one-line Javascript program (created in 2003), it should also
work in Konqueror i think.
But yes, it would work in Micro$oft Internet Exploder as well (as
everything will work in it, even things that should NOT be working).
Then paste 1 of these javascript lines i the adress-bar and press
[Enter].

No, don't.

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
T

Thomas 'PointedEars' Lahn

Martie said:
Thomas said:
Martie said:
royg567 wrote:
Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.
Open your requested page in the browser.

So that would not include the most recent version of Konqueror …

[x] You only know Microsoft Internet Explorer.
I'm not using Micro$oft Internet Exploder, i'm using Safari (version
5.0.3) as the browser (it works here).

So at least you know that there is more than one browser. And that did not
make you think?
I't is a one-line Javascript program (created in 2003),

There is no "Javascript". The ECMAScript implementation that Safari
supports could only reasonably be named JavaScriptCore, after its script
engine. But that is only what Safari supports.
it should also work in Konqueror i think.

Konqueror does not support `javascript:' URIs in the Address Bar to date. If
it would, using your code verbatim would have the same undesired side-
effects as in other browsers, assuming the script worked as designed.
But yes, it would work in Micro$oft Internet Exploder as well (as
everything will work in it, even things that should NOT be working).

There are so many things wrong with that piece of code that I do not know
where to begin. It is very unlikely that it works reliably outside of the
one tested browser version. Do not use it, and learn programming first.


PointedEars
 
D

Dr J R Stockton

In comp.lang.javascript message <01b1f7ee-0cf1-43a7-b3a7-9b97a5c90259@f3
0g2000yqa.googlegroups.com>, Sat, 19 Feb 2011 06:53:55, royg567
Can anyone advise how to read data from a web page using javascript ?
I am reasonably adept at programming in a number of languages. My
ultimate goal is to read a web page on which there are a number of
links to subordinate pages, each of which contains a table with data
which I would like to process.

You can, at least, read it into an iframe, as I do in my linxchek.htm,
js-grphx.htm, pageindx.htm sitedata.htm (approximate decreasing order of
complexity).

Be warned, though, that JavaScript in a web browser should only read
pages from the same domain, and some browsers either do not like
implicit file: protocols or have peculiar ideas on what then constitutes
a domain.

You can, I think, do more by putting the script in an HTA or executing
JScript with WSH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top