Friday, August 1st, 2008
Greg Murray has blogged about a new release candidate for Aptana Jaxer that contains a lot of new features.
Kevin Hakman told us about the release:
Here are the features:
- Application context settings that allowing for easier app configuration, app properties, database settings, etc…
- Database API enhancements with richer APIs for working with result sets.
- Server-side image manipulation including server-side canvas support and ability to convert to other image types.
- Native command execution API so that you can run system commands and handle the output from those.
- Ability to return custom content types (e.g. json, xml, gif, html, etc…)
- Full control of the request/response lifecycle including setting redirects, headers, content, etc…
Uri Sarid has a great post that shows how you can do DOM Scraping with Jaxer, and updates it for this latest release:
There’s a lot of other new goodness in Jaxer 1.0, as well as the official released version of the Mozilla engine found in Firefox 3. So for example getElementsByClassName is natively implemented (see John Resig’s speed comparison), in addition to the other Mozilla features such as built-in XPath functionality and a very robust DOM feature set — just what you need for some serious ‘screen scraping’, mashups, and content repurposing.
Let’s see it in action!
It includes code that shows the Sandbox in action, as well as the DOM work:
- // Gets a fragment of the remote page's HTML, after some cleanup
- function getFragment(title, url, isClassName, identifier, classesToRemove)
- var sandbox = new Jaxer.Sandbox(url);
- var contents = sandbox.document[isClassName ? 'getElementsByClassName' : 'getElementById'](identifier);
- var container = addToPage(title, contents);
- if (classesToRemove)
- if (typeof classesToRemove == "string") classesToRemove = [classesToRemove];
- return container.innerHTML;
- getFragment.proxy = true;
Posted by Dion Almaer at 1:51 pm