擅长:python、mysql、java
<pre><code>from contextlib import closing
from selenium.webdriver import Firefox # pip install selenium
from selenium.webdriver.support.ui import WebDriverWait
from BeautifulSoup import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# use firefox to get page with javascript generated content
with closing(Firefox()) as driver:
driver.get("http://www.att.com/shop/wireless/devices/smartphones.html")
button = driver.find_element_by_id('deviceShowAllLink')
button.click()
# wait for the page to load
element = WebDriverWait(driver, 10).until(
EC.invisibility_of_element_located((By.ID, "deviceShowAllLink"))
)
# store it to string variable
page_source = driver.page_source
soup = BeautifulSoup(page_source)
items = soup.findAll('div', {"class": "list-item"})
print "items count:",len(items)
</code></pre>
<p>这会有帮助吗。。?在</p>