PDA

View Full Version : Need Help With Fetching Data From Other Webpages


genetic^eyes
12-01-2005, 06:12 PM
Hi guys,
Am trying to come up with a Javascript function that can load a given URL and fetch part/whole of the web page and hand it over to my parser. Any ideas on how to do it ?

One way I figured is to use XMLHttpRequest - but you need the server-end to respond by sending the required data to you in XML format. What if the page I want to extract data from is just an ordinary static page ... say I know the required data is a word that can be found at second paragraph of a page.. So how do I go about getting that page and extracting that info.

Any help will be much appreciated :)

Regards,
genetic^eyes

Mr J
12-01-2005, 08:44 PM
With regards to getting the page, it may be a bit unorthodox but you could load it into an hidden iframe using visibility:hidden, it would have to be visibility and not display:none because NS7 does not want to play ball if display is used.

genetic^eyes
12-01-2005, 09:11 PM
Can you direct me to some code with which this can be done ? Any examples would be really good... :)

Meanwhile, if there's any method to fetch the page directly - like one can do with the XMLHttpRequest - that'd be even better. What I'm trying to do is fetch this page, extract some info and display it in the Firefox Statusbar. The UI part I got done - only barrier now is to fetch the page. If only PHP could be used in conjunction with XUL in FF Extensions - I wouldn't have any problems.. Fetching a page like this is extremely easy with the cURL extension in PHP.

Thanks for your reply anyways :)

liorean
12-01-2005, 11:00 PM
XMLHttpRequest can be used to load any document, not just XML. Mozilla needs the the content type to be overridden for anything that is not well formed XML, but it can be used for anything, really.