View Single Post
10-27-12, 12:52 AM   #8
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
I've done a lot of similar parsing for _NPCScan.Overlay, so I rearranged my Python 3 scripts to pull your mailbox locations into a Lua source file. I left out my MPQ parsing code since it requires you to build a DLL, so this version reads DBC files directly. The attached zip contains:
  • WorldMapArea.dbc extracted for you; May need to get the latest version from your data files if new maps with mailboxes get added in a patch.
  • mailboxes.py - The actual scraping script.
  • dbc.py - A simple module for reading DBC files.
  • mailboxes.bat - Windows batch file to run the above script with default parameters.
  • mailboxes.lua - The sample output file my run created.

Note that you'll need Python 3.2+ to run the scripts, and you must install BeautifulSoup4 to interpret WoWDB's HTML.

Here's how it works in summary:
  1. Download the raw HTML for object 142075 (mailbox) from WoWDB.
  2. Interpret the text as HTML using a forgiving XML parser.
  3. Search the resulting document tree for a div with ID "mapper-container" with BeautifulSoup.
  4. The script tag following that div contains JavaScript defining map points. Strip off the "Mapper" constructor call with a regex, and parse the contained argument table as JSON.
  5. The table's contents are pretty straight-forward, but maps are represented by their AreaTable IDs (no WoW API exposes these) instead of their MapArea IDs (what you get from GetCurrentMapAreaID). This is where WorldMapArea.dbc comes in to convert to IDs you can use within WoW.
  6. Write it.

Feel free to ask any questions about the script if it interests you. If not though, I think the included Lua source should be good enough to use.
Attached Files
File Type: zip mailboxes.zip (14.2 KB, 429 views)

Last edited by Saiket : 10-27-12 at 02:52 PM. Reason: Added attachment, and actually *uploaded* it this time.
  Reply With Quote