我已经用python编写了一个脚本来抓取类floorplan中的某个文本,该类位于right-column
中,该类位于modal-body
中。但是,当我运行脚本时,它会给出空白输出?你知道吗
单击前的元素(值在floorplan
和swing
类中为空):
<div class="right-column">
<div class="field" ng-show="selectedLot.Name !== ''">
<div class="label">Home Design:</div>
<div class="floorplan value ng-binding"></div>
<hr>
</div>
<div class="field" ng-show="selectedLot.ShortDescription !== ''">
<div class="label">Elevation:</div>
<div class="swing value ng-binding"></div>
<hr>
</div>
<div class="field" ng-show="selectedLot.Swing !== ''">
<div class="label">Swing:</div>
<div class="swing value ng-binding"></div>
<hr>
</div>
</div>
单击后(值现在位于floorplan
和swing
类中):
<div class="right-column">
<div class="field" ng-show="selectedLot.Name !== ''">
<div class="label">Home Design:</div>
<div class="floorplan value ng-binding">Delaware</div>
<hr>
</div>
<div class="field" ng-show="selectedLot.ShortDescription !== ''">
<div class="label">Elevation:</div>
<div class="swing value ng-binding">TRA</div>
<hr>
</div>
<div class="field" ng-show="selectedLot.Swing !== ''">
<div class="label">Swing:</div>
<div class="swing value ng-binding">Garage Right</div>
<hr>
</div>
</div>
到目前为止,我已经尝试了(can't make my script click on that image to reveal the data I'm after
):
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def collect_links(link):
driver.get(link)
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR,"path#ip-loader-circle")))
item = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR,".modal-body .right-column .floorplan")))
print(item.get_attribute("innerHTML"))
if __name__ == '__main__':
url = "https://khovsecure.ml3ds-cloud.com/index.html?_ga=2.181197287.1174152084.1550480313-902396065.1550480313#/lotmap/43935"
driver = webdriver.Chrome()
wait = WebDriverWait(driver,20)
collect_links(url)
driver.quit()
预期产量:
Delaware
这就是当点击地图时,信息是如何在框中弹出的:
How can I make a click on that map to scrape the desired text from the pop up container?
下面的代码提供json格式的所有数据:
相关问题 更多 >
编程相关推荐