X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fyppedia-ocean-scraper;h=5e5e0901f563b097b6554b891e04cf184f89b45a;hp=d55f7acab83d7d0a03ae21655059e4277e1e9068;hb=ac0ff0f496aaa83b013c0102ee8e4e4076d150b4;hpb=1457a9e8d2e5ddda2b05b658e69df1b80a07320d diff --git a/yarrg/yppedia-ocean-scraper b/yarrg/yppedia-ocean-scraper index d55f7ac..5e5e090 100755 --- a/yarrg/yppedia-ocean-scraper +++ b/yarrg/yppedia-ocean-scraper @@ -88,16 +88,18 @@ def fetch(): url_base = 'index.php?title=Template:Map:%s_Ocean&action=edit' else: url_base = '%s_Ocean' - url = ('http://yppedia.puzzlepirates.com/' + - (url_base % urllib.quote(ocean,''))) - debug('fetching',url) - dataf = urllib.urlopen(url) - debug('fetched',dataf) + url_base = url_base % urllib.quote(ocean,'') + if opts.localhtml is None: + url = ('http://yppedia.puzzlepirates.com/' + url_base) + debug('fetching',url) + dataf = urllib.urlopen(url) + debug('fetched',dataf) + else: + dataf = file(opts.localhtml + '/' + url_base, 'r') soup = BeautifulSoup(dataf) - title_arch_re = regexp.compile('(\\S.*\\S) Archipelago \\((\\S+)\\)$') -title_any_re = regexp.compile('(\\S.*\\S) \((\\S+)\\)$') +title_any_re = regexp.compile('(\\S.*\\S) \((\\S+)\\)(?: \(page does not exist\))?$') href_img_re = regexp.compile('\\.png$') def title_arch_info(t): @@ -189,6 +191,9 @@ def main(): help='print chart source rather than arch/island info') ao('--debug', action='count', dest='debug', default=0, help='enable debugging output') + ao('--local-html-dir', action='store', dest='localhtml', + help='get yppedia pages from local directory LOCALHTML'+ + ' instead of via HTTP') (opts,args) = pa.parse_args() if len(args) != 1: