【问题标题】:Loop through List of urls and pulling off stock available循环浏览网址列表并提取可用库存
【发布时间】:2021-04-26 12:20:36
【问题描述】:

我有 15,000 个网页,所有网页的格式都在 A 列中,我需要提取每种产品的可用库存并将其粘贴到 H 列。我尝试了多种在网上找到的解决方案,但均未成功。

我的第一个网址是:view-source:https://www.coolings.co.uk/shop/products/plants/bedding/all-bedding/osteospermum-mixed-10-5cm-pot.html

我要的图就坐在这里(125):

<div class="availability-wrapper">
      <div class="availability in-stock">125 available</div>
  </div>

任何帮助表示赞赏。

【问题讨论】:

标签: excel vba scrape


【解决方案1】:

这是一个示例,用于从您提供的 URL 获取可用库存。您必须遍历所有 URL 并相应地调整代码:

Sub getStock()
    Dim IE As Object, Doc As Object, Ele As Object
    
    Set IE = CreateObject("internetexplorer.application")
    IE.navigate "https://www.coolings.co.uk/shop/products/plants/bedding/all-bedding/osteospermum-mixed-10-5cm-pot.html"

    Do While IE.ReadyState <> 4 Or IE.Busy: DoEvents: Loop
    
    Set Doc = IE.Document
    Set Ele = Doc.getElementsByClassName("availability in-stock")
    
    Debug.Print Ele(0).innerText
    IE.Quit
    Set IE = Nothing: Set Doc = Nothing: Set Ele = Nothing
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 2020-10-14
    • 2016-08-08
    • 1970-01-01
    • 2020-01-02
    • 2021-01-16
    • 2018-12-08
    相关资源
    最近更新 更多