how to using code to download these java scripted page link ?

K

key9

Hi all

I am writting some download application using c++
the main idea is using "socket" to get html page.

and find the download link ,and using HTTP protocol to download it.


but how to deal with these page links which contain java scripts?


for example
there's a botton on browers and wrote:
"click to download"


how I can analysis these html code and got the link?
by invoking browser's API? and how?
by invoking jvm? and how?

and ideas?


thank you very much


your key9
 
B

Benjamin Niemann

Good evening,
I am writting some download application using c++
the main idea is using "socket" to get html page.

and find the download link ,and using HTTP protocol to download it.


but how to deal with these page links which contain java scripts?


for example
there's a botton on browers and wrote:
"click to download"


how I can analysis these html code and got the link?
by invoking browser's API? and how?
by invoking jvm? and how?

You are confusing Java and JavaScript. A jvm is for Java.
and ideas?

The best way (but hardly practical): convince all
webmasters/-developers/-author not to build websites which rely on
JavaScript ;)

If you can implement such a beast, it will probably be pretty unique - at
least I don't know of any such tool. Even big corporations like Google and
MS with lots of money and developers to throw at such problems, build
webspiders which simply ignore JS.

The only way I could think of, though I don't know, if I would work in any
sensible way:

Use a JavaScript engine, e.g. 'Spider Monkey'
<http://www.mozilla.org/js/spidermonkey/> to execute the embedded
JavaScript of the documents you download. But this is just the pure
JavaScript core. You'd still have to implement all objects which are
provided by the browser, e.g. 'document', 'window', ... - and emulate their
behaviour.

Then search all elements of the document for installed event handlers and
invoke these events. Install some kind of callback which is invoked, when a
value is assigned to window.location.href.

I think, you'll be busy for quite a while ;)


HTH
 
D

David Dorward

key9 wrote:
I am writting some download application using c++
the main idea is using "socket" to get html page.
and find the download link ,and using HTTP protocol to download it.

So you're writing an HTTP client and an HTML parser from scratch? Why?
but how to deal with these page links which contain java scripts?

You either write a JavaScript interpreter from scratch or you use a
preexisting library (which you should probably be doing for the other parts
of your project).
by invoking jvm? and how?

Java and JavaScript are different languages. You don't use a Java Virtual
Machine to interpret JavaScript.
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top