[英]Selenium + bs4 choosing right data before scraping it
我想從這個站點https://www.marketbeat.com/insider-trades/ceo-share-buys-and-sales/抓取數據。 問題是我想在抓取之前選擇一些選項
在“國家/地區”按鈕中,我想檢查每個按鈕
這是默認 state
抓取數據后,我想重復這個過程,但是
交易類型 已售股票已勾選
現在我有https://colab.research.google.com/drive/1VUVSI5BGiN5lCFrj4WGfJaZg1-wtU2f1?usp=sharing
如果有人能給我一些提示,我將不勝感激,謝謝
這應該有效。 您必須單擊標簽而不是復選框
dropdownButton = driver.find_element(By.ID, 'dropdownCountry');
dropdownButton.click();
dropdownList = driver.find_element(By.XPATH, '//ul[@aria-labelledby="dropdownCountry"]')
countryButtons = dropdownList.find_elements(By.TAG_NAME, "label");
countryButtons.pop(0)
for i in countryButtons:
i.click()
soldSharesButton = driver.find_element(By.XPATH, '//option[@value="Sell"]')
soldSharesButton.click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.