Selenium定時重新整理網頁

1treeS發表於2019-02-16

程式碼

程式碼很簡單,主要是為了熟悉Selenium這個庫的函式,為後續的簡訊轟炸做個鋪墊

from selenium import webdriver
import time
import random

url = raw_input(`Input your website:`).strip()
num = int(raw_input(`How much times do you want:`),10)
options = webdriver.FirefoxOptions()
options.add_argument(`--headless`)
browser = webdriver.Firefox(firefox_options=options)
browser.get(url)
print `Please wait...`
for i in range(num):
    i += 1
    print `Refresh +%d` %i
    time.sleep(random.randint(1,3))
    browser.refresh()
browser.quit()
print `Good Bye!`

END

相關文章