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

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

刮除隱藏元素

刮除隱藏元素

aluckdog 2021-05-30 06:00:26
我的問題是雙重的:1) 我正在嘗試使用下面的代碼登錄此頁面,源在此處??梢允褂梦姨峁┑膽{據,該憑據將在28天后過期,但是為之后查看此內容的用戶創建一個試用帳戶相對容易。from selenium import webdriverdriver_path = 'Path to my downloaded chromedriver.exe file'url_login = 'https://www.findacode.com/signin.html'username = '[email protected]'password = 'm%$)-Y95*^.1Gin+'options = webdriver.ChromeOptions()options.add_argument('headless')driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)driver.get(url_login)assert '_submit_check' in driver.page_sourcedriver.find_element_by_name('id').send_keys(username)driver.find_element_by_name('password').send_keys(password)driver.find_element_by_xpath("//input[@value='Sign In']").submit()我收到所有 3 個元素的以下錯誤:selenium.common.exceptions.ElementNotVisibleException: Message: element not visible我對 html/css/javscript 的命令沒有那么強,但我嘗試過使用每個線程的等待并收到超時。接下來打算從該線程嘗試 ActionChains,但很想聽聽對此有更多了解的人如何繼續。2)最終,我想通過在循環中改變代碼(url 的最后 5 個字符)從這個url(源here)中抓取特定的代碼歷史數據。用戶必須登錄,因此我上面的第一個問題是,在瀏覽器中查看我想要的信息的方法是展開淺紫色的“代碼歷史”表。我需要的具體信息是“操作”列為“已添加”且“注釋”列為“已添加代碼”的任何行中的日期:Date       Action Notes 2018-01-01 Added  First appearance in code2017-02-01 Added  Code Added我在這里的問題是,由于我認為表格是隱藏的,因此需要通過單擊來擴展該表格以顯示我要查找的數據,我該如何進行?編輯 這里的代碼、偽代碼和評論來解釋我的第二個問題。url_code = "https://www.findacode.com/code.php?set=CPT&c="driver.get(url_code+'0001U') # i'm presuming that this will preserve the login sessiondriver.find_element_by_id('history').click() # i intend for this to expand the Code History section and expose the table shown earlier in the post but it's not doing thatcheck whether the phrase "Code Added" occurs in page sourceif so, grab the date that is in the <td nowrap> tag that is 2 tags to the left如果無法使用Selenium,我可以在后兩行中使用BeautifulSoup,但是我需要幫助了解為什么我看不到要抓取的數據
查看完整描述

2 回答

?
幕布斯7119047

TA貢獻1794條經驗 獲得超8個贊

有網頁兩種形式與投入@name="id",@name="password"以及“登錄”按鈕。第一個是隱藏的。您需要使用以下方式處理表單@name="login":


form = driver.find_element_by_name('login')

form.find_element_by_name('id').send_keys(username)

form.find_element_by_name('password').send_keys(password)

form.find_element_by_xpath("//input[@value='Sign In']").submit()


查看完整回答
反對 回復 2021-06-01
  • 2 回答
  • 0 關注
  • 125 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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