def workQunarLowest(): db = DB('atp', 'atp', 'atp') q = QunarLowest(db.getConn(), getAllAirport(), RECENT_DAY_RANGE) q.crawlAllAirlinesWithRetry(RETRY_TIMES)
def workQunarLowest(): db = DB("atp", "atp", "atp") q = QunarLowest(db.getConn(), getAllAirport(), RECENT_DAY_RANGE) q.crawlAllAirlinesWithRetry(RETRY_TIMES)
L.info("{} -> {}", depInfo[0], arrInfo[0]) bs = BeautifulSoup(r.text, 'lxml-xml') resultData = bs.find('ResultData') for airline in resultData.children: if airline.name == 'lowestPrice': d = airline.attrs allAttrs = ('date', 'code', 'depTime', 'arrTime', 'carrier', 'vendorName', 'price') attrOK = True for attr in allAttrs: if attr not in d: attrOK = False break if not attrOK: continue info = FlightLowestPriceInfo(queryDate, queryTime, depInfo[0], arrInfo[0], [d[x] for x in allAttrs]) # print info.asRec() self.dbHandle.insertOneRec(info) return ER_SUCC if __name__ == '__main__': db = DB('atp', 'atp', 'atp') q = QunarLowest(db.getConn(), getAllAirport(), 60) q.crawlAllAirlinesWithRetry(5)
if r.status_code != 200: L.error("{} -> {} failed, url={}", depInfo[0], arrInfo[0], url) return ER_RESPONSE_FAIL L.info("{} -> {}", depInfo[0], arrInfo[0]) bs = BeautifulSoup(r.text, 'lxml-xml') resultData = bs.find('ResultData') for airline in resultData.children: if airline.name == 'lowestPrice': d = airline.attrs allAttrs = ('date', 'code', 'depTime', 'arrTime', 'carrier', 'vendorName', 'price') attrOK = True for attr in allAttrs: if attr not in d: attrOK = False break if not attrOK: continue info = FlightLowestPriceInfo(queryDate, queryTime, depInfo[0], arrInfo[0], [d[x] for x in allAttrs]) # print info.asRec() self.dbHandle.insertOneRec(info) return ER_SUCC if __name__ == '__main__': db = DB('atp', 'atp', 'atp') q = QunarLowest(db.getConn(), getAllAirport(), 60) q.crawlAllAirlinesWithRetry(5)