niexiaosu8167
niexiaosu8167
2017-10-03 18:41

beautifulsoup 爬虫问题

  • 爬虫
  • selenium
  • beautifulsoup

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,找不出问题在哪里了,请问如何解决

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答