Re: [問題] selenium開網頁一直卡在查詢紐

看板Python作者 (海洋)時間9月前 (2023/08/01 01:10), 編輯推噓3(303)
留言6則, 2人參與, 9月前最新討論串2/2 (看更多)
1) search_button 那一行沒有找到正確的元件 可以改成 driver.find_element(By.XPATH, '//*[@id="search_bar1"]/div/input') 2) search_button.click() 改成 search_button.send_keys('\n') 至少這樣在我這邊是動得起來的 : 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), 來自: 35.10.41.97 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1690823458.A.D70.html

08/01 10:47, 9月前 , 1F
08/01 10:47, 1F

08/01 10:53, 9月前 , 2F
我的查詢紐還是不能動耶 不過沒有跑到except的print了
08/01 10:53, 2F

08/01 12:17, 9月前 , 3F
or try search_button.submit()
08/01 12:17, 3F

08/01 15:36, 9月前 , 4F
search_button.submit()也是不行T_T
08/01 15:36, 4F

08/01 16:31, 9月前 , 5F
'//*[@id="search_bar1"]/div/input[@type="button"]'
08/01 16:31, 5F

08/01 16:32, 9月前 , 6F
Xpath改成以上用search_button.click()也可以了,謝謝你
08/01 16:32, 6F
文章代碼(AID): #1an-iYrm (Python)
文章代碼(AID): #1an-iYrm (Python)