How to get the runtime value

B

Ben

I posted on this forum several days ago and got helpful replies. but,
most replies directed to html file download. I rephrase my question
here.

I am working on a project collecting data from web. Since there are
many URLs I need to visit and manually copy the data, I am thinking to
automate this job.

I plan to use WSH to retrieve the webpages, extract the values and save
those numbers to a local fie.(Please let me know if you have better
solutions.) However, the javascipt becomes my enemy this time.

I made a simple example here.
-----------------------
<html> <body>
<script>
n1 = 25
v1 = '<a href="a.htm"> file_' + n1 + '</a>'
document.write(v1)
</script>
</body> </html>
------------------------

v1 is equal to '<a href="a.htm"> file_25 </a>'. However, the runtime
value of v1 is not retrievable from the downloaded file.

If I need to get the runtime value of v1, what should I do?

Thanks,

Ben
 
E

Evertjan.

Ben wrote on 04 jan 2007 in comp.lang.javascript:
I posted on this forum several days ago and got helpful replies. but,
most replies directed to html file download. I rephrase my question
here.

I am working on a project collecting data from web. Since there are
many URLs I need to visit and manually copy the data, I am thinking to
automate this job.

I plan to use WSH to retrieve the webpages, extract the values and save
those numbers to a local fie.(Please let me know if you have better
solutions.) However, the javascipt becomes my enemy this time.

I made a simple example here.
-----------------------
<html> <body>
<script>
n1 = 25
v1 = '<a href="a.htm"> file_' + n1 + '</a>'
document.write(v1)
</script>
</body> </html>
------------------------

v1 is equal to '<a href="a.htm"> file_25 </a>'. However, the runtime
value of v1 is not retrievable from the downloaded file.

If I need to get the runtime value of v1, what should I do?

I have no idea what you mean by "runtime value" here.
You can simply do something like: alert(v1)

If you want to retrieve the content of the body element,
use innerHTML

<html> <body onload='alert(document.body.innerHTML)'>
<script type='text/javascript'>
var n1 = 25
var v1 = '<a href="a.htm"> file_' + n1 + '</a>'
document.write(v1)
</script>
</body> </html>

==============================

I doubt if the above will bring you to automaic fetching.

Why, as I showed you before, not use XMLHTTP GET?

If you can get the content of the html files downloaded,
you will be in the clear, or not?
 
B

Ben

Dear Evertjan,

I followed your suggestion to use XMLHTTP GET. The problem is I need
to copy the values saved in variables which are dynamically generated
when the javascript is executed in a web browser.

When I download the file from web, it is a plain html text. I have to
open the file in a web browser to manually copy the string. In this
example, it is saved in v1 and equals
'<a href="a.htm"> file_25 </a>'.

Thanks.

Ben
 
V

VK

Ben said:
I am working on a project collecting data from web. Since there are
many URLs I need to visit and manually copy the data, I am thinking to
automate this job.

I plan to use WSH to retrieve the webpages, extract the values and save
those numbers to a local fie.(Please let me know if you have better
solutions.) However, the javascipt becomes my enemy this time.

I made a simple example here.
-----------------------
<html> <body>
<script>
n1 = 25
v1 = '<a href="a.htm"> file_' + n1 + '</a>'
document.write(v1)
</script>
</body> </html>
------------------------

Sign it off on my part but I'm still not clear about the exact
procedure. Could you please provide a URL of a page similar to one you
are working with? That doesn't have to be a real page from your set -
though that would be optimal - just any page having a similar data in
similar form.
Then just comment on this URL by steps:
1) get the URL
2) find ...
3) ...
 
E

Evertjan.

Ben wrote on 04 jan 2007 in comp.lang.javascript:
Evertjan. wrote:

[Please, PLEASE do not toppost on usenet,
and only quote what is relevant to your reply,
so also do not copy the signature, below the --]
I followed your suggestion to use XMLHTTP GET. The problem is I need
to copy the values saved in variables which are dynamically generated
when the javascript is executed in a web browser.

As long as you know the clientside code, you can dublicate that in your
code. I suppose some serverside starting values must be brought to the
client?
When I download the file from web, it is a plain html text. I have to
open the file in a web browser to manually copy the string. In this
example, it is saved in v1 and equals
'<a href="a.htm"> file_25 </a>'.

Yes, you are working without the help or the approval of the page owner,
it seems. So you will have to do some work analyzing his page yourself,
and completely understand the clientside code. How else would you know
where in the text the values are you want?

Else you would have to break into the DOM,
which seems very difficult to automate.

Please do not infringe on an other's copyright.
 
B

Ben

Yes. This is exactly what I want to say. What I want is not the source
code. I want to get the saved data in javascript variables.
 

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

No members online now.

Forum statistics

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

Latest Threads

Top