Created
April 6, 2014 08:10
-
-
Save RomanVlasenko/10002897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
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.get("http://www.kinopoisk.ru/film/596001/") | |
try: | |
#Ждем 10 сек. пока загрузится элемент на странице (в данном случае <table class='info'>), можно добавлять несколько для уверенности | |
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "table.info"))) | |
#Записываем body страницы в переменную | |
pageBody = driver.find_element_by_css_selector('body').get_attribute("outerHTML") | |
finally: | |
driver.quit() | |
text_file = open("output.txt", "w") | |
text_file.write(pageBody.encode('utf-8')) | |
text_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment