#!/usr/bin/python
# -*- coding: utf-8 -*-
mydir = "./"
pwbdir = mydir + "pywikipedia/"

import sys
sys.path.append(pwbdir)
from wikipedia import *

import urllib
import json

paths = (("IHhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AInterstate+Highway+System+articles")),
         ("IHmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AInterstate+Highway+System+articles")),
         ("USHhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AU.S.+Highway+system+articles")),
         ("USHmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AU.S.+Highway+system+articles")),
         ("AUTOhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AU.S.+auto+trail+articles")),
         ("AUTOmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AU.S.+auto+trail+articles")),
         ("US66hardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AU.S.+Route+66+articles")),
         ("US66missing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AU.S.+Route+66+articles")),
         ("ALhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AAlabama+road+transport+articles")),
         ("ALmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AAlabama+road+transport+articles")),
         ("AKhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AAlaska+road+transport+articles")),
         ("AKmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AAlaska+road+transport+articles")),
         ("AZhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AArizona+road+transport+articles")),
         ("AZmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AArizona+road+transport+articles")),
         ("ARhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AArkansas+road+transport+articles")),
         ("ARmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AArkansas+road+transport+articles")),
         ("CAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ACalifornia+road+transport+articles")),
         ("CAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ACalifornia+road+transport+articles")),
         ("COhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AColorado+road+transport+articles")),
         ("COmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AColorado+road+transport+articles")),
         ("CThardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AConnecticut+road+transport+articles")),
         ("CTmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AConnecticut+road+transport+articles")),
         ("DEhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ADelaware+road+transport+articles")),
         ("DEmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ADelaware+road+transport+articles")),
         ("FLhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AFlorida+road+transport+articles")),
         ("FLmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AFlorida+road+transport+articles")),
         ("GAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AGeorgia+(U.S.+state)+road+transport+articles")),
         ("GAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AGeorgia+(U.S.+state)+road+transport+articles")),
         ("HIhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHawaii+road+transport+articles")),
         ("HImissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHawaii+road+transport+articles")),
         ("IDhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AIdaho+road+transport+articles")),
         ("IDmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AIdaho+road+transport+articles")),
         ("ILhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AIllinois+road+transport+articles")),
         ("ILmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AIllinois+road+transport+articles")),
         ("INhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AIndiana+road+transport+articles")),
         ("INmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AIndiana+road+transport+articles")),
         ("IAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AIowa+road+transport+articles")),
         ("IAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AIowa+road+transport+articles")),
         ("KShardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AKansas+road+transport+articles")),
         ("KSmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AKansas+road+transport+articles")),
         ("KYhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AKentucky+road+transport+articles")),
         ("KYmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AKentucky+road+transport+articles")),
         ("LAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALouisiana+road+transport+articles")),
         ("LAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALouisiana+road+transport+articles")),
         ("MEhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMaine+road+transport+articles")),
         ("MEmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMaine+road+transport+articles")),
         ("MDhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMaryland+road+transport+articles")),
         ("MDmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMaryland+road+transport+articles")),
         ("MAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMassachusetts+road+transport+articles")),
         ("MAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMassachusetts+road+transport+articles")),
         ("MIhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMichigan+road+transport+articles")),
         ("MImissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMichigan+road+transport+articles")),
         ("MNhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMinnesota+road+transport+articles")),
         ("MNmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMinnesota+road+transport+articles")),
         ("MShardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMississippi+road+transport+articles")),
         ("MSmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMississippi+road+transport+articles")),
         ("MOhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMissouri+road+transport+articles")),
         ("MOmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMissouri+road+transport+articles")),
         ("MThardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMontana+road+transport+articles")),
         ("MTmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMontana+road+transport+articles")),
         ("NEhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANebraska+road+transport+articles")),
         ("NEmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANebraska+road+transport+articles")),
         ("NVhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANevada+road+transport+articles")),
         ("NVmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANevada+road+transport+articles")),
         ("NHhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANew+Hampshire+road+transport+articles")),
         ("NHmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANew+Hampshire+road+transport+articles")),
         ("NJhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANew+Jersey+road+transport+articles")),
         ("NJmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANew+Jersey+road+transport+articles")),
         ("NMhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANew+Mexico+road+transport+articles")),
         ("NMmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANew+Mexico+road+transport+articles")),
         ("NYhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANew+York+road+transport+articles")),
         ("NYmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANew+York+road+transport+articles")),
         ("NChardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANorth+Carolina+road+transport+articles")),
         ("NCmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANorth+Carolina+road+transport+articles")),
         ("NDhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ANorth+Dakota+road+transport+articles")),
         ("NDmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ANorth+Dakota+road+transport+articles")),
         ("OHhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AOhio+road+transport+articles")),
         ("OHmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AOhio+road+transport+articles")),
         ("OKhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AOklahoma+road+transport+articles")),
         ("OKmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AOklahoma+road+transport+articles")),
         ("ORhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AOregon+road+transport+articles")),
         ("ORmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AOregon+road+transport+articles")),
         ("PAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0APennsylvania+road+transport+articles")),
         ("PAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0APennsylvania+road+transport+articles")),
         ("RIhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ARhode+Island+road+transport+articles")),
         ("RImissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ARhode+Island+road+transport+articles")),
         ("SChardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ASouth+Carolina+road+transport+articles")),
         ("SCmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ASouth+Carolina+road+transport+articles")),
         ("SDhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ASouth+Dakota+road+transport+articles")),
         ("SDmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ASouth+Dakota+road+transport+articles")),
         ("TNhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ATennessee+road+transport+articles")),
         ("TNmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ATennessee+road+transport+articles")),
         ("TXhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ATexas+road+transport+articles")),
         ("TXmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ATexas+road+transport+articles")),
         ("UThardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AUtah+road+transport+articles")),
         ("UTmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AUtah+road+transport+articles")),
         ("VThardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AVermont+road+transport+articles")),
         ("VTmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AVermont+road+transport+articles")),
         ("VAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AVirginia+road+transport+articles")),
         ("VAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AVirginia+road+transport+articles")),
         ("WAhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AWashington+road+transport+articles")),
         ("WAmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AWashington+road+transport+articles")),
         ("WVhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AWest+Virginia+road+transport+articles")),
         ("WVmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AWest+Virginia+road+transport+articles")),
         ("WIhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AWisconsin+road+transport+articles")),
         ("WImissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AWisconsin+road+transport+articles")),
         ("WYhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AWyoming+road+transport+articles")),
         ("WYmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AWyoming+road+transport+articles")),
         ("GUhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AGuam+road+transport+articles")),
         ("GUmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AGuam+road+transport+articles")),
         ("PRhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0APuerto+Rico+road+transport+articles")),
         ("PRmissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0APuerto+Rico+road+transport+articles")),
         ("VIhardcoded", ("hardcoded", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AU.S.+Virgin+Islands+road+transport+articles")),
         ("VImissing", ("missing", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AU.S.+Virgin+Islands+road+transport+articles")),
         ("highBHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")),
         ("midBHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")),
         ("lowBHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")),
         ("BHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AB-Class+U.S.+road+transport+articles")),
         ("highCHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("midCHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("lowCHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("CHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AC-Class+U.S.+road+transport+articles")),
         ("highStartHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("midStartHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("lowStartHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("StartHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("highStubHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("midStubHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("lowStubHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("StubHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("highFutureHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("midFutureHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("lowFutureHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("FutureHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("highHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles")),
         ("midHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0AMid-importance+U.S.+road+transport+articles")),
         ("lowHardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list%0D%0ALow-importance+U.S.+road+transport+articles")),
         ("Hardcoded", ("overall", "U.S.+Roads+project+articles+with+a+hardcoded+junction+list")),
         ("highCMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("midCMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("lowCMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")),
         ("CMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AC-Class+U.S.+road+transport+articles")),
         ("highStartMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("midStartMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("lowStartMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("StartMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AStart-Class+U.S.+road+transport+articles")),
         ("highStubMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("midStubMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("lowStubMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("StubMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AStub-Class+U.S.+road+transport+articles")),
         ("highFutureMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("midFutureMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("lowFutureMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("FutureMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AFuture-Class+U.S.+road+transport+articles")),
         ("highMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AHigh-importance+U.S.+road+transport+articles")),
         ("midMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0AMid-importance+U.S.+road+transport+articles")),
         ("lowMissing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list%0D%0ALow-importance+U.S.+road+transport+articles")),
         ("Missing", ("overall", "U.S.+Roads+project+articles+needing+a+junction+list"))
        )

cells = {}
status = {"hardcoded": [], "missing": [], "overall": []}
hardcoded = 0
missing = 0
both = 0
done = 0

for k,v in paths:
    print "Retrieving stat {0}.".format(k)
    response = urllib.urlopen("https://tools.wmflabs.org/quick-intersection/index.php?lang=en&project=wikipedia&ns=1&depth=12&max=30000&start=0&format=json&callback=&cats=" + v[1])
    if response.getcode() == 200:
        content = response.readline()
        data = json.loads(content)
        count = data["pagecount"]
        cells[k] = count
        status[v[0]].append(count)
    else:
        raise IOError

for i in range(len(status["hardcoded"])):
    hc = status["hardcoded"][i]
    ms = status["missing"][i]
    if hc > 0:
        hardcoded += 1
        if ms > 0:
            both += 1
            missing += 1
    elif ms > 0:
        missing += 1
    else:
        done += 1

cells["done"] = done
cells["hardcoded"] = hardcoded
cells["missing"] = missing
cells["both"] = both

from datetime import date
cells["date"] = date.today().isoformat()

site = wikipedia.getSite("en","wikipedia")
page = wikipedia.Page(site,"User:Happy5214/jctint Tables")
content = page.get()

import re
def countrepl(matchobj):
    return u"|" + matchobj.group(1) + u"=" + unicode(cells[matchobj.group(1)])

newcontent = re.sub(r'\|(\w+)\=(\d{4}-\d{2}-\d{2}|\d+)', countrepl, content)
page.put(newcontent, u"Update")