4 signal.signal(signal.SIGINT, signal.SIG_DFL)
10 #from optparse import OptionParser
12 from BeautifulSoup import BeautifulSoup
16 url = 'http://yppedia.puzzlepirates.com/%s_Ocean' % urllib.quote(ocean,'')
17 dataf = urllib2.urlopen(url)
19 soup = BeautifulSoup(dataf)
21 title_arch_re = regexp.compile('\\S+ Archipelago \\((\\S+)\\)$')
22 title_any_re = regexp.compile('(\\S.*\\S) \((\\S+)\\)$')
23 href_img_re = regexp.compile('\\.png$')
25 def title_arch_arch(t):
27 if t is None: return None
28 m = title_arch_re.match(t)
33 a = title_arch_arch(t)
34 if a is None: return False
37 firstarch = soup.find('a', attrs = {'title': title_arch_ok})
38 print 'fa',`firstarch`
40 archestable = firstarch.findParent(
41 lambda u: u.name == 'table' and
42 len(u.findAll('a', attrs = {'title': title_arch_ok})) > 1
45 print 'at',`archestable`
47 arches = archestable.findAll('a', attrs = {'title': title_arch_ok})
50 arches = map((lambda u: u.findParent(
51 lambda v: len(v.findAll(text= regexp.compile('.*Large'))) > 0
56 links = arch.findAll('a', href=True)
57 print 'links', `links`
58 a = title_arch_arch(links[0]['title'])
61 for link in links[1:]:
63 if href_img_re.search(link['href']): continue
64 m = title_any_re.match(link['title'])
65 assert(m.group(2) == ocean)