【发布时间】:2018-11-04 22:14:32
【问题描述】:
我正在为 scrape 网站“yelp.fr”编写脚本,但要废弃该类自动生成的星数: class="i-stars i-stars--regular-4 rating-large" ==> 4 次开始 class="i-stars i-stars--regular-3-half rating-large" ==> 3.5
我的问题是如何做到这一点?以及如何判断类是否存在于 html 页面上
CITIES = "la rochelle(17000)"
places = "Bars"
driver = webdriver.Chrome()
driver.get("https://www.yelp.fr/search?find_desc="+places+"&find_loc="+CITIES+"")
page = driver.page_source
soup = BeautifulSoup(page,"lxml")
etoiles=soup.find_all("div",{"class":"biz-rating biz-rating-large clearfix"})
etoiles.get_attribute("title")
if etoiles:
print "ok"
else:
print "not "
【问题讨论】:
标签: python selenium-webdriver beautifulsoup selenium-chromedriver