您可以使用Selenium Webdriver:
#!/usr/bin/env pythonfrom contextlib import closingfrom selenium.webdriver import Firefox # pip install seleniumfrom selenium.webdriver.support.ui import WebDriverWait# use firefox to get page with javascript generated contentwith closing(Firefox()) as browser: browser.get(url) button = browser.find_element_by_name('button') button.click() # wait for the page to load WebDriverWait(browser, timeout=10).until( lambda x: x.find_element_by_id('someId_that_must_be_on_new_page')) # store it to string variable page_source = browser.page_sourceprint(page_source)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)