I wrote a really simple JavaScript script that uses jQuery to extract all the categories from Facebook's "Create a page" page.
- Navigate to the Create a page page.
- jQuerify the page.
- Open up your JavaScript console of choice and run the following script:
(function () {
var categories = {};
// Get the value/text of each category <option> on the page
$jq("select[name=category] option").each(function () {
categories[$jq(this).val()] = $jq(this).text();
});
// Delete the "Choose a category" default option
delete categories["0"];
// Print a JSON string of all the categories
return JSON.stringify(categories);
})();
How can this be adapted for another website?
Eg:
Given a website that has multiple product category,
When I run a variation of this script,
Then a json containing the product category will be generated,
And the category will also contain all child categories.