[問題] selenium開網頁一直卡在查詢紐
selenium版本 4.10 , python版本 3.10.9
最近開始學python,卡在這個問題好久了
也沒有error message,年度可以自動填入111但就是查詢紐一直不能click
然後程式就跳到except的print message ~> <~
請教各位大大,問題到底出在哪裡,謝謝各位的指教
import os
from selenium import webdriver # open browser
import time #休息時間
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/
20100101 Firefox/115.0'
firefox_driver = os.path.join(os.getcwd(), 'driver','geckodriver.exe')
firefox_service = Service(firefox_driver)
firefox_option = Options()
firefox_option.set_preference('general.useragent.override', user_agent)
driver = webdriver.Firefox(service=firefox_service, options=firefox_option)
url = 'https://mops.twse.com.tw/mops/web/t152sb01'
driver.get(url) # 前往這個網站
try:
ticker = '111'
print(ticker,"Start searchinh!")
keyword = driver.find_element(By.ID,"year")
keyword.send_keys(ticker)
search_button = driver.find_element(By.CSS_SELETOR,"#search_bar1 div.
search input[type=button]")
print(ticker,"test222")
search_button.click()
time.sleep(2)
except:
print(ticker,"Start searchinh2!")
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.217.193.234 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1690821154.A.5EC.html
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章