【问题标题】:How to scrape dynamically generated data in this website?如何抓取本网站动态生成的数据?
【发布时间】:2016-07-11 11:59:37
【问题描述】:

这里是我要抓取的网站http://www.quickbid.com.tw/

我希望我可以将 class="timestamp" 放入 python 中的变量中,以便我可以按照我喜欢的方式解析“timestamp”。

我试过用scrapy来抓取“时间戳”,但是因为scrapy不支持javascript生成的数据,所以我无法获取。

我还尝试使用 firebug 来监控“quickbid”和我的浏览器之间传输的数据包。我发现每秒都有数据包被传输以同步时间戳。但是我仍然不知道这些数据包是如何生成的。 我听说也许 Selenium 可以帮助我实现目标。但是看了 Selenium 的教程(http://www.jroller.com/selenium/),我还是不知道如何抓取我想要的数据。

有人知道如何从这个网站上抓取数据吗?任何帮助将不胜感激。

【问题讨论】:

标签: javascript python selenium web-scraping firebug


【解决方案1】:

我通常使用基本请求和 BeautifulSoup 库进行报废。我这样做了:

import requests
from bs4 import BeautifulSoup
r = requests.get("http://www.quickbid.com.tw/")
c = r.content
soup = BeautifulSoup(c,'html.parser')
timestanp = soup.findAll('span',{'class':'timestamp'})
print timestanp

它返回了:

[<span class="timestamp">Save91%</span>, <span class="timestamp">Save84%</span>, <span class="timestamp">Save96%</span>, <span class="timestamp">Save99%</span>, <span class="timestamp">Save82%</span>]

希望这是您正在寻找的。​​p>

【讨论】:

    【解决方案2】:

    你绝对可以用 Selenium 做到这一点。事实上这很容易。 Selenium 具有适用于许多不同编程语言的插件,因此只需选择您更了解的一种并阅读该特定语言的 Selenium 文档即可。

    我个人使用python,很容易理解。

    这里是selenium documentation for Python

    【讨论】:

      【解决方案3】:

      我终于使用了一个名为 Greasemonkey 的 Firefox 插件来抓取网站。

      https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

      Greasemonkey 可以在http://www.quickbid.com.tw/ 中捕获动态生成的数据

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-16
        • 1970-01-01
        • 1970-01-01
        • 2020-10-27
        • 2015-07-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多