2015-09-29 64 views
-2

我試圖從Link中獲取一些信息。我想要獲取的數據是公司名稱,電子郵件,電話號碼,位置並將其粘貼到Excel表格中。請建議一些fromework /一種方法來刮取數據並將其寫入xls。我知道xlwt是一個框架。如何從網頁中獲取數據並將其粘貼到excel中

from selenium import webdriver 
from selenium.common.exceptions import NoSuchElementException 
from selenium.webdriver.common.keys import Keys 
import time 


browser = webdriver.Firefox() # Get local session of firefox 

# 0 wait until the pages are loaded 
browser.implicitly_wait(3) # 3 secs should be enough. if not, increase it 

browser.get("http://ae.bizdirlib.com/taxonomy/term/1493") # Load page 
#links =[] 
#link=browser.find_elements_by_class_name('term-listing-heading') 
#links = browser.find_elements_by_css_selector("h2 > a") 

#print link 
#for link in links: 
# link.send_keys(Keys.CONTROL + Keys.RETURN) 
# link.send_keys(Keys.CONTROL + Keys.PAGE_UP) 
# time.sleep(2) 
# link.send_keys(Keys.CONTROL + 'w') 

回答

0

嘗試使用this Python的例子來幫助你學習如何刮的頁面,然後使用openpyxl創建一個Excel工作表:

我寫打開一個標籤,並獲取信息的代碼下面給出。

相關問題