Archive for January, 2012

Circumvent Wikipedia’s Blackout with Firefox and NoScript

Today the English version of Wikipedia is blacked out to protest the SOPA legislation that is on the books in the United States. Sources say that people wishing to access Wikipedia can still do so using the mobile version of the site; however, this is unnecessary as they are using simple Javascript to overlay the site content with the “Blacked Out” message.

To access Wikipedia from your computer today:

  1. Install the most recent version of firefox
  2. Install the NoScript addon

By default, NoScript blocks all javascript, the code used to blackout Wikipedia is prevented from running.

Read more about NoScript at Lifehacker.

, , ,

No Comments

Parse HTML with ActionScript’s EX4

ActionScript includes an EX4 implementation that allows easy parsing of XML in code. I wanted to parse HTML for screen scraping purposes and found that EX4 allows for a syntax that loosely resembles a combination of XPATH and css3 selectors.

Josh’s tutorial provided a very good foundation; however, I was finding that I was having problems doing attribute-based filtering in the case where the attribute name is the same as an ActionScript keyword. This was especially problematic as I needed to filter based on the contents of the HTML element’s class attribute.

After much investigation I found that while the HTML tag names were in the default namespace, the attribute names were not. As a result, If i set a default namespace for the XML parsing, I could not access the attribute values if I listed their names as strings. However, I found if I created a new QName object with a blank namespace, the attributes would be returned as expected.

default xml namespace = new Namespace("http://www.w3.org/1999/xhtml");
var xml:XML = XML(htmlString);
var results:XMLList = xml..span.(attribute(new QName(new Namespace(""), "class")) == "foo")

The above will return a list of all span objects with a class attribute of “foo”

, , , ,

No Comments