#!/bin/env python
# -*- encoding:utf-8 -*-
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.set_window_size(1366, 768)
driver.get("
http://www.kuaidaili.com/")
time.sleep(10)
bodyStr= driver.find_element_by_tag_name("table").get_attribute("innerHTML")
print bodyStr
很好抓呀,当然,要是觉得 time.sleep(10)太 low
#!/bin/env python
# -*- encoding:utf-8 -*-
from selenium import webdriver
from
selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
driver.set_window_size(1366, 768)
driver.get("
http://www.kuaidaili.com/")
wait = WebDriverWait(driver, 10)
wait.until(
EC.presence_of_element_located((By.CSS_SELECTOR, ".table-bordered"))
)
bodyStr= driver.find_element_by_tag_name("table").get_attribute("innerHTML")
print bodyStr