def __init__(self, root, path): self.root = root self.path = path self.isGoodStatus = False self.urllist, self.isPageFile = path2urlList(root, path) if checkPath(self.urllist): self.url = self.urllist[-1] self.resp = headRequestCached(self.url) if isGoodStatus(self.resp): self.isGoodStatus = True
def checkPath(path): d = len(path) for i in xrange(0, d - 1): resp = headRequestCached(path[i]) if isGoodStatus(resp) and isPage(resp): content = getRequestCached(path[i]) urls = getURLs(content, path[i]) if path[i + 1] not in urls: return False else: return False return True