from bs4 import BeautifulSoup
from selenium import webdriver
import urllib2
import time
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.zillow.com/homes/recently_sold/Culver-City-CA/house,condo,apartment_duplex,townhouse_type/20432063_zpid/51617_rid/12m_days/globalrelevanceex_sort/34.048605,-118.340178,33.963223,-118.47785_rect/12_zm/")
time.sleep(3)
driver.find_element_by_class_name("collapsible-header").click()
soup = BeautifulSoup(driver.page_source)
region = soup.find("div",{"id":"hdp-price-history"})
table = region.find('table',{'class':'zsg-table yui3-toggle-content-minimized'})
print table
需要price/Tax history 的table但是通过class和id定位的结果是None,找不出问题在哪里了
查找下页面是不是有相同的id 根据class取得是个数组
看看print(region) 输出的内容,没有table 标签,如果find?
<div class="zsg-tab-panel zsg-tab_active loading yui3-widget yui3-async-block yui3-complaintstable yui3-hdppricehistory yui3-hdppricehistory-content" id="hdp-price-history"><div class="zsg-content-section zsg-loading-spinner_lg"></div></div>
你鼠标点不到这个地方。