當前位置: 首頁>>代碼示例>>Python>>正文


Python Recorder.writeN方法代碼示例

本文整理匯總了Python中recorder.Recorder.writeN方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.writeN方法的具體用法?Python Recorder.writeN怎麽用?Python Recorder.writeN使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在recorder.Recorder的用法示例。


在下文中一共展示了Recorder.writeN方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getFlightPrice

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import writeN [as 別名]
def getFlightPrice(driver, url, id, worker_num):
    """
    This function send url to remote server and get the result.
    Save the result into file.
    Input parameter: 
        dirver: The web driver.
        url: type[string] . The url address.
        id: type[int] The flight id.
        worker_num: type[int] the worker number.
    """
#     flight_module_class_name='flight-module.segment.offer-listing'

        
    flight_id=str(id)
    
    re = Recorder(flight_id,recorder.RecorderMode.binary)
    
    if runDriver(driver,url,id)==True:
        #Write the fight id.
        flight_id="<flight_id>"+flight_id
        re.writeN(flight_id)
        
        #Write the url
        re.write("<url>")
        re.writeN(url)
        
        #Write the search date
        t = datetime.datetime.now().strftime("%Y-%m-%d %H %M %S")
        search_date = "<search_date>"+t
        re.writeN(search_date)

        #Write the worker number
        re.write("<worker_num>")
        re.writeN(str(worker_num))

          
        time.sleep(1)
        body_element = driver.find_element_by_tag_name('body')
        re.writeN(body_element.text)

        time.sleep(1)
        re.finish()
    else:
        print("worker[%d] failed to handle flight_id[%d]" %(worker_num, id))
開發者ID:jingwangian,項目名稱:flight,代碼行數:46,代碼來源:worker_exec.py


注:本文中的recorder.Recorder.writeN方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。