Example #1
0
def analysis_lowest(dep_code, arr_code):
    result_map = ResultMap()
    db = DB('atp', 'atp', 'atp')
    conn = db.getConn()
    cursor = conn.cursor()
    cursor.execute(
        "select * from FLIGHT_LOWEST_PRICE_INFO where dep_code='%s' and arr_code='%s'"
        % (dep_code, arr_code))
    # print cursor.rowcount
    while True:
        result = cursor.fetchone()
        # print result
        if not result:
            break

        query_date = result[1]
        dep_date = result[5]
        price = result[11]
        result_map.add((dep_date - query_date).days, price)

    print 'FROM:%s    TO:%s' % (dep_code, arr_code)
    result_map.analysis()
Example #2
0
def workQunarLowest():
    db = DB('atp', 'atp', 'atp')
    q = QunarLowest(db.getConn(), getAllAirport(), RECENT_DAY_RANGE)
    q.crawlAllAirlinesWithRetry(RETRY_TIMES)
Example #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)