如何从网页获取数据并将其粘贴到Excel中

时间:2015-09-29 18:10:07

标签: excel python-2.7 selenium selenium-webdriver xlwt

我正在尝试从此http://jsfiddle.net/wNKcU/5/获取一些信息。我想要获取的数据是公司名称,电子邮件,电话,位置并将其粘贴到Excel工作表中。请建议一些fromework /一种方法来刮取数据并将其写入xls。我知道xlwt是一个框架。

我编写的用于打开标签和获取信息的代码如下:

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')

1 个答案:

答案 0 :(得分:0)

尝试使用this python示例来帮助您了解如何抓取页面,然后使用openpyxl创建Excel工作表。

相关问题