亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

selenium 連接到網頁時如何執行循環?

selenium 連接到網頁時如何執行循環?

翻過高山走不出你 2022-04-27 13:36:32
我試圖讓它在通過硒連接到網頁時循環。這是代碼:from sys.stdout import flushfrom sys import argvfrom selenium import webdriverdef loading():    print("Loading.\r")    flush()    print("Loading..\r")    flush()    print("Loading...\r")    flush()driver = mydriverslocationwebsite = argv[1]driver.get(website)# Do loading() while connecting to website那么我如何loading()在連接到網站的同時撥打電話?
查看完整描述

1 回答

?
至尊寶的傳說

TA貢獻1789條經驗 獲得超10個贊

最好的辦法是并行。我知道一種方法,但可能有更有效的方法來做到這一點。


import threading

from sys.stdout import flush

from sys import argv

from selenium import webdriver


website_loaded = False


def loading():

    while not website_loaded:

        print("Loading.\r")

        flush()

        print("Loading..\r")

        flush()

        print("Loading...\r")

        flush()


driver = mydriverslocation

website = argv[1]


# Start the loading thread

# Expected method to run, and arguments.

loading_thread = threading.Thread(loading, ())

loading_thread.start()


driver.get(website)

# And any other code while loading


# This will pass to the thread

website_loaded = True


查看完整回答
反對 回復 2022-04-27
  • 1 回答
  • 0 關注
  • 132 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號