Skip to content

Instantly share code, notes, and snippets.

@ZhangZhongwei73671
Created May 9, 2018 02:41
Show Gist options
  • Save ZhangZhongwei73671/76b5ef799239f6e20040035514c8322a to your computer and use it in GitHub Desktop.
Save ZhangZhongwei73671/76b5ef799239f6e20040035514c8322a to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
import time
caps = webdriver.DesiredCapabilities().FIREFOX
caps["marionette"] = True
binary = FirefoxBinary(r'f:\firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
for i in range(0,18):
driver.get("https://zh.airbnb.com/s/shenzhen--china/homes?refinement_paths%5B%5D=%2Fhomes&page1=&cdn_cn=1&s_tag=_bVwCdeI&allow_override%5B%5D=&section_offset=" + str(i))
rent_list = driver.find_elements_by_css_selector('div._gig1e7')
for eachhouse in rent_list:
comment = eachhouse.find_element_by_css_selector('div._36rlri')
comment = comment.text
price = eachhouse.find_element_by_css_selector('div._1yarz4r')
price = price.text[4:]
name = eachhouse.find_element_by_css_selector('div._17djt7om')
name = name.text
details = eachhouse.find_elements_by_css_selector('div._sp05107')
detail_list = [i.text for i in details]
house_type = detail_list[0]
#no_bed = detail_list[1]
#no_visitor = detail_list[2]
print(comment+"条评论", price, name, house_type)
#print(no_bed, no_visitor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment