close

anaconda安裝用Selenium

主要是因為爬蟲沒辦法直接看到JS的渲染

 

 

from selenium import webdriver

driver = webdriver.PhantomJS(executable_path=r'C:\Users\USER\Desktop\phantomjs-2.1.1-windows\phantomjs-2.1.1-windows\bin\phantomjs.exe')  # PhantomJs
driver.get('http://pala.tw/js-example/')  # 輸入範例網址,交給瀏覽器 
pageSource = driver.page_source  # 取得網頁原始碼
print(pageSource)

driver.close()  # 關閉瀏覽器

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 阿亮 的頭像
    阿亮

    阿喨的部落格

    阿亮 發表在 痞客邦 留言(0) 人氣()