首页 > 解决方案 > 为什么我的 webscraper 返回 [] 到 powershell?

问题描述

我使用 python、BeautifulSoup 和 Selenium 的网络爬虫返回 "[]" 。最初我只是使用 BeautifulSoup 并且遇到了同样的问题,因为我试图抓取的是天气数据,所以我尝试使用 selenium。这是代码和html片段,我对此很陌生,所以提前谢谢你:)

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time

driver = webdriver.Chrome()

driver.get("https://wx.ikitesurf.com/spot/93670")

time.sleep(5)

windspeed = driver.find_elements_by_class_name("jw-spot-list-marker")

print (windspeed)
  
driver.close() 

html

<span class="jw-list-view-wind-desc">9 (g15) mph W</span>

标签: pythonseleniumweb-scrapingbeautifulsoupwebdriver

解决方案


推荐阅读