[英]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.