def hits(self, url): self.conn.request("POST", "/search/" + url, self.params, self.headers) response = self.conn.getresponse().read().decode("windows-1252", errors="ignore") parser = HTMLPartsParser("tr", {"class" : ["first-line"]}) parser.feed(response) return parser.matches
def updateCurrency(currencyId): html = getCurrencyHTML(currencyId) parser = HTMLPartsParser("div", {"class" : ["displayoffer-middle"]}) parser.feed(html) matches = parser.matches if len(matches) > MAX_CURRENCY_COUNT_FOR_AVG: matches = matches[:MAX_CURRENCY_COUNT_FOR_AVG] sum = 0 for match in matches: (to, chaos) = match.split("⇐") sum += float(chaos) / float(to) CURRENCYS[Currency(currencyId)] = sum / MAX_CURRENCY_COUNT_FOR_AVG