【问题标题】:Scrapy + Splash Rendering a JavaScript dataScrapy + Splash 渲染 JavaScript 数据
【发布时间】:2017-11-20 07:23:19
【问题描述】:

我正在尝试使用 scrapysplash 来废弃电子商务网站,因为页面上的大部分内容都是由 JS 呈现的动态内容strong>,我正在使用 splash 来获取数据。我能够获取除价格数据之外的所有其他数据。

<div class="grid-row rendered">
    <span data-id="from-price" data-bind="visible: showFromLabel, text: fromLabelText, css: { 'price-from-discounted' : isDiscountedPrice }" class="price-from" style="display: none;">From</span>
    <span data-id="current-price" data-bind="text: priceText(), css: {'product-price-discounted' : isDiscountedPrice }" class="current-price">$31.58</span>
    <span data-id="rrp-price" data-bind="text: rrpPriceText, visible: showRrpPrice" class="product-prev-price" style="display: none;"></span>
    <span data-id="previous-price" data-bind="text: prevPriceText, visible: showPrevPrice" class="product-prev-price" style="display: none;"></span>
    <span data-id="german-vat-message" data-bind="text: germanVatMessage, visible: showGermanVatMessage" class="product-german-vat" style="display: none;"></span>
</div>

我想获取第二个跨度数据,但是当我print(response.body) 时,渲染的div.grid-row 没有渲染。

我怎样才能得到那个价格数据。

这是page的链接

【问题讨论】:

    标签: javascript python-3.x web-scraping scrapy-spider scrapy-splash


    【解决方案1】:

    终于解决了这个问题,我用splash在scrapy shell中运行网页,然后当我执行view(response)时,结果发现价格部分没有加载,然后我搜索了一下,找到了这个answer, 基本上,我只需要按照链接中的答案所示在私人模式下运行启动画面。

    【讨论】:

      猜你喜欢
      • 2017-03-08
      • 2018-05-30
      • 2017-12-11
      • 2020-05-04
      • 2018-02-13
      • 1970-01-01
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多