miCRoSCoPiC^eaRthLinG 0 Report post Posted December 1, 2005 Hi guys, [tab][/tab]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, m^e Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted December 1, 2005 Umm.. easiest way I know of to do this is to use sockets, which is networking, and not one of javascripts strong suits. May I inquire as to why it is important that it be javascript?~Viz Share this post Link to post Share on other sites
miCRoSCoPiC^eaRthLinG 0 Report post Posted December 2, 2005 Because it's for a firefox extension - I need to be able to connect to a certain Asta page and extract a "certain" info lol..See the thing is javascript has a really cool XML Client Service - a class known as XMLHttpRequest - which is extremely painless, as it's asynchronous. That means it will connect to the server on a separate thread, without slowing down the main code. It even has a callback delegate, which receives the reply upon termination of the request.. but anyway, for that you need something at the server end that serves the data in XML format. What I'm looking for here is any other alternative by which I can fetch a page and extract certain info out of it. Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted December 2, 2005 Cool, I'll keep an eye out on one condition, that you write an in depth firefox extension tutorial when you get a chance .~Viz Share this post Link to post Share on other sites
miCRoSCoPiC^eaRthLinG 0 Report post Posted December 2, 2005 Cool - will do so. And actually - forget about the JS Code. When I went to sleep last night I had a dream of an alternative ( I know it's weird - people dream real sweet dreams - and I dream coding solutions .. and when I wake up in the morning - THEY WORK.. I get most of my solutions in dream). Anyways - I wrote of a XML-RPC script using PHP - that'd serve the data in XML format and was able to read it off using the XMLHttpRequest class of JavaScript. So... the Firefox Credits Reporting System Extension is FINISHED and FULLY WORKING. It's under thorough testing now.. hopefully I'll be able to release it simultaneously for Xisto and Xisto within 4-5 days. Only feature that hasn't been implemented yet - is auto-refreshing of credits at a preset duration. Right one, it refreshes upon a single click with the left mouse button. Other than that you obviously have to set your own username password into it - otherwise it won't fetch credits. This user/pass combo is stored in the central Mozilla PasswordManager Safe So no worries about that.. this part took a while to figure out. Earlier they're getting saved in plaintext to prefs.js - which of course is visible to everyone. Upon finishing this extension I realized how poorly documented (and explained) are extension tutorials. I couldn't find a SINGLE GOOD one on the net - ultimately I had to rip apart every possible extension and study them whole night till I started seeing light. Other than that the Mozilla Extension API references helped to a certain extent - although their Examples are by far few and poor. I gave the extension FOUR Distinct States - i.e. it's got this Xisto Icon (also Xisto) .. converted to appropriate format+colors by twitch/guy .. Sneak Previews The basic idea is: Credits 30+ : BLUE 15 <= Credits < 30 : GREEN 1 < Credits < 15 : AMBER Credits <= 1 : RED Any bright ideas, any UI considerations - let me know for sure, and I'll see if it can be incorporated using my limited knowledge Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted December 2, 2005 Cool, suggestion, add a mod mode to it so mods and Admins can eneter someone's username to view their credit count. That will make it easier to diagnose credit problems maybe, and speed up credit checking for applications.~Viz Share this post Link to post Share on other sites
vujsa 0 Report post Posted December 4, 2005 One additional state should be added. - Error / Unknown / UnavailableIn the event auxilary credit display script which I assume you are using is offline, your scipt may be very upset about it. I didn't program the credit checker for the Free Web Hosting application script to deal with that well and it has caused a bit of a stir.vujsa Share this post Link to post Share on other sites