Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use JavaScript to fetch source of a page 1

Status
Not open for further replies.

quarryknight

Programmer
Jan 1, 2005
29
US
Before you yell at me for posting with malicious intent, hear me out:

I am currently working on a price comparison website for the textbooks that my college sells (since they overprice everything). My goal is to fetch the source of a page on Half.com to get the currently lowest price of a textbook by ISBN.

I was wondering it is possible to do such a thing with JavaScript, and if possible, how would I go about getting started. Since JavaScript is client-side, I may not be able to do it at all. If it is impossible to do so with JavaScript, would I be able to do it with PHP or ASP?

Thank you very much for your time.

Nick Ruiz
Webmaster, DBA
 
I *guess* you could open the page in an iframe or in a new window and call [tt]newpage.document.body.innerHTML[/tt], but it is much easier in PHP, as in use one built-in function: file_get_contents(), I believe.

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Glorious, simply glorious. It parses the price very nicely.

I really didn't want to have to use JavaScript, since my page runs primarily on PHP anyway. Thanks for the help.

Nick Ruiz
Webmaster, DBA
 
Not a problem; glad to help.

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top