コード例 #1
0
def workQunarLowest():
    db = DB('atp', 'atp', 'atp')
    q = QunarLowest(db.getConn(), getAllAirport(), RECENT_DAY_RANGE)
    q.crawlAllAirlinesWithRetry(RETRY_TIMES)
コード例 #2
0
ファイル: start_work.py プロジェクト: extrainfo/ATP
def workQunarLowest():
    db = DB("atp", "atp", "atp")
    q = QunarLowest(db.getConn(), getAllAirport(), RECENT_DAY_RANGE)
    q.crawlAllAirlinesWithRetry(RETRY_TIMES)
コード例 #3
0
        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)
コード例 #4
0
ファイル: qunar_lowest.py プロジェクト: extrainfo/ATP
            
        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)