Jump to content
xisto Community
miCRoSCoPiC^eaRthLinG

Javascript: Help With Fetching Data From Webpages

Recommended Posts

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

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

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

Posted Image

 

 

15 <= Credits < 30 : GREEN

Posted Image

 

 

1 < Credits < 15 : AMBER

Posted Image

 

 

Credits <= 1 : RED

Posted Image

 

 

 

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.