import time from datetime import datetime from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait # from selenium.webdriver.chrome.service import Service chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') # 无界面模式 browser = webdriver.Chrome(chrome_options=chrome_options) i = 1 while i < 3: try: browser.get( 'https://ezil.me/personal_stats?wallet=你的钱包地址&coin=eth') # print(browser.current_url) # print(browser.page_source) now = datetime.now() str_time = str(now.strftime("%Y-%m-%d,%H:%M:%S")) txt1 = browser.find_elements_by_css_selector('.ezil-wb0bqw') num1 = str_time + ',' + txt1[0].text txt2 = browser.find_elements_by_css_selector('.ezil-1n3mmjs') num2 = num1 + ',' + txt2[2].text print(num2) with open('c:\ezil.txt', 'a+') as f: f.write(num2+'\n') f.close() finally: #i += 1 time.sleep(120) browser.quit()
比格高
逼格更高