2014-12-10 19 views

cevap

22

.page_source yılında yazdırmak yoktur:

>>> from selenium import webdriver 
>>> driver = webdriver.Firefox() 
>>> driver.get('http://google.com') 
>>> print(driver.page_source) 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" itemtype="http://schema.org/WebPage" itemscope=""><head><meta name="descri 
... 
:before,.vscl.vslru div.vspib{top:-4px}</style></body></html> 
+2

Teşekkür ederim, bu tam da ihtiyacım olan şey! Bu benim hatamdı çünkü ben bunu kötü bir şekilde yaptım 'print driver.page_source' (driver.page_source parantez içinde değildi) – wmarchewka

0

Sen HTML sayfası kaynağını tarayıcı kullanmadan da alabilir. İstek modülü bunu yapmanızı sağlar.

import requests 

res = requests.get('https://google.com') 
res.raise_for_status() # this line trows an exception if an error on the 
         # connection to the page occurs. 
print(res.text) 
İlgili konular