dcsimg
Results 1 to 3 of 3

Thread: Webscraping tables from different pages not working (hyperlink does not change)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2020
    Posts
    1

    Webscraping tables from different pages not working (hyperlink does not change)

    Hello All,

    I have a basic knowledge of VBA but webscraping, javascript etc is completely new for me.
    I have been trying to figure out how to extract (3) tables from the following url: Export Fundamental Data U.S. and International Stocks - QuickFS.net
    Through a dropdown I need to get to the Incomestatement, Balance sheet and Cashflow Statement
    When I inspect the elements I think below html / javascript statement (s) is the key.

    Income Statement <table class="fs-table" id="is-table">
    Balance Sheet <table class="fs-table" id="bs-table">
    Cashflow Statement <table class="fs-table" id="cf-table">

    The table class remains the same whilst the id refers to the different statements

    I managed some code to access the Income Statement, but I can not figure out how to get to the others

    I would really appreciate if anybody can help me out here
    --------------------------------------------------------------------------------------------------------------
    Sub GetQuickfs()
    Dim IE As New InternetExplorer, html As HTMLDocument
    Dim elem As Object, data As String
    webaddress = "Export Fundamental Data U.S. and International Stocks - QuickFS.net"

    With IE
    .Visible = False
    .navigate webaddress
    Do While .readyState <> READYSTATE_COMPLETE: Loop
    Set html = .document
    End With

    For Each elem In html.getElementsByClassName("fs-table")(0).getElementsByTagName("td")

    data = elem.innerText
    Debug.Print data
    Next elem
    IE.Quit
    End Sub

    ------------------------------------------------------------------------------------------------------------------------------------------------
    ReplyReport

  2. #2
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,196

    Re: Webscraping tables from different pages not working (hyperlink does not change)

    Quote Originally Posted by MLUY View Post
    Hello All,

    I have a basic knowledge of VBA but webscraping, javascript etc is completely new for me.
    I have been trying to figure out how to extract (3) tables from the following url: Export Fundamental Data U.S. and International Stocks - QuickFS.net
    Through a dropdown I need to get to the Incomestatement, Balance sheet and Cashflow Statement
    When I inspect the elements I think below html / javascript statement (s) is the key.

    Income Statement <table class="fs-table" id="is-table">
    Balance Sheet <table class="fs-table" id="bs-table">
    Cashflow Statement <table class="fs-table" id="cf-table">

    The table class remains the same whilst the id refers to the different statements

    I managed some code to access the Income Statement, but I can not figure out how to get to the others

    I would really appreciate if anybody can help me out here
    --------------------------------------------------------------------------------------------------------------
    Sub GetQuickfs()
    Dim IE As New InternetExplorer, html As HTMLDocument
    Dim elem As Object, data As String
    webaddress = "Export Fundamental Data U.S. and International Stocks - QuickFS.net"

    With IE
    .Visible = False
    .navigate webaddress
    Do While .readyState <> READYSTATE_COMPLETE: Loop
    Set html = .document
    End With

    For Each elem In html.getElementsByClassName("fs-table")(0).getElementsByTagName("td")

    data = elem.innerText
    Debug.Print data
    Next elem
    IE.Quit
    End Sub

    ------------------------------------------------------------------------------------------------------------------------------------------------
    ReplyReport
    Export Fundamental Data U.S. and International Stocks - QuickFS.net isn't actually a URL, it looks more like the title of a page - what is the actual URL of the webpage?

    A quick search turned up https://quickfs.net which is where I am assuming the data is from, if so https://quickfs.net/pricing lists that they have an API to provide this data in the paid plans. Their terms https://quickfs.net/terms expressly forbid scrapping the HTML as well.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,852

    Re: Webscraping tables from different pages not working (hyperlink does not change)

    For Each elem In html.getElementsByClassName("fs-table")(0).getElementsByTagName("td")
    looks like you would need a 0 to 2 loop for "fs-table" classname
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width