def getLocation(phoneNumber): htmlGraber = HtmlGraber() url = serviceUrl + "?m=" + phoneNumber content = htmlGraber.doGrab(url) content = content.replace("<br/><br/>", "||") items = content.split("||") # print items[1]; return items[1] if __name__ == "__main__": pass fileUtil = FileUtil() content = fileUtil.openFile(phoneSrc) # print content; content = content.replace("\r", " ").replace("\t", " ").replace("\n", " ") # print content; items = content.split(" ") items = [item for item in items if item != ""] output = "" index = 1 for i in range(len(items)): if i % 2 == 1: print index index += 1 location = getLocation(items[i]) itemstr = items[i] + " " + location + "\n"