How do I parse a WebPage using HTML tags in VBScript












0















I try to extract the price of Bitcoin from https://coinmarketcap.com/ using VBScript.
I have the following HTML code:






<td class="no-wrap text-right" data-sort="4329.6071152">
<a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
</td>





So I wrote this script for the vbs file:



set objIE =nothing
Set objIE = CreateObject("InternetExplorer.Application")

objIE.Visible = false
objIE.Navigate "https://coinmarketcap.com/"

Do
WScript.Sleep 100
Loop Until objIE.ReadyState = 4

msgbox objIE.document.getElementsByTagName("/currencies/bitcoin/#markets")
objIE.Quit()


My expected result is "4329.6071152" but the actual result is:
enter image description here










share|improve this question





























    0















    I try to extract the price of Bitcoin from https://coinmarketcap.com/ using VBScript.
    I have the following HTML code:






    <td class="no-wrap text-right" data-sort="4329.6071152">
    <a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
    </td>





    So I wrote this script for the vbs file:



    set objIE =nothing
    Set objIE = CreateObject("InternetExplorer.Application")

    objIE.Visible = false
    objIE.Navigate "https://coinmarketcap.com/"

    Do
    WScript.Sleep 100
    Loop Until objIE.ReadyState = 4

    msgbox objIE.document.getElementsByTagName("/currencies/bitcoin/#markets")
    objIE.Quit()


    My expected result is "4329.6071152" but the actual result is:
    enter image description here










    share|improve this question



























      0












      0








      0








      I try to extract the price of Bitcoin from https://coinmarketcap.com/ using VBScript.
      I have the following HTML code:






      <td class="no-wrap text-right" data-sort="4329.6071152">
      <a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
      </td>





      So I wrote this script for the vbs file:



      set objIE =nothing
      Set objIE = CreateObject("InternetExplorer.Application")

      objIE.Visible = false
      objIE.Navigate "https://coinmarketcap.com/"

      Do
      WScript.Sleep 100
      Loop Until objIE.ReadyState = 4

      msgbox objIE.document.getElementsByTagName("/currencies/bitcoin/#markets")
      objIE.Quit()


      My expected result is "4329.6071152" but the actual result is:
      enter image description here










      share|improve this question
















      I try to extract the price of Bitcoin from https://coinmarketcap.com/ using VBScript.
      I have the following HTML code:






      <td class="no-wrap text-right" data-sort="4329.6071152">
      <a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
      </td>





      So I wrote this script for the vbs file:



      set objIE =nothing
      Set objIE = CreateObject("InternetExplorer.Application")

      objIE.Visible = false
      objIE.Navigate "https://coinmarketcap.com/"

      Do
      WScript.Sleep 100
      Loop Until objIE.ReadyState = 4

      msgbox objIE.document.getElementsByTagName("/currencies/bitcoin/#markets")
      objIE.Quit()


      My expected result is "4329.6071152" but the actual result is:
      enter image description here






      <td class="no-wrap text-right" data-sort="4329.6071152">
      <a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
      </td>





      <td class="no-wrap text-right" data-sort="4329.6071152">
      <a class="price" href="/currencies/bitcoin/#markets" data-btc="1.0" data-usd="4329.6071152">$4,329.61</a>
      </td>






      parsing vbscript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 12:12







      BOB

















      asked Nov 23 '18 at 11:55









      BOBBOB

      4481618




      4481618
























          2 Answers
          2






          active

          oldest

          votes


















          2














          You're getting a collection of HTML nodes with your query. You should try a more specific one and also getting its attributes:



          MsgBox objIE.document.QuerySelectorAll("a[href='/currencies/bitcoin/#markets']").Item(0).getAttribute("data-usd")


          image






          share|improve this answer
























          • Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

            – BOB
            Nov 23 '18 at 12:54











          • If I want to extract "$4,329.61" how can I do? Because it's a little bit different

            – BOB
            Nov 23 '18 at 13:00






          • 1





            @BOB You can use .innerText for that.

            – iBug
            Nov 23 '18 at 13:29





















          1














          Since the row of the table has the id attribute set. You can get the text content of the cell this way:



          objIE.document.GetElementById("id-bitcoin").Cells(3).InnerText





          share|improve this answer
























          • It's working but where did you get "id-bitcoin" ?

            – BOB
            Nov 23 '18 at 13:09











          • I saw it <tr id="id-bitcoin" class="odd" role="row">

            – BOB
            Nov 23 '18 at 13:10











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446261%2fhow-do-i-parse-a-webpage-using-html-tags-in-vbscript%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You're getting a collection of HTML nodes with your query. You should try a more specific one and also getting its attributes:



          MsgBox objIE.document.QuerySelectorAll("a[href='/currencies/bitcoin/#markets']").Item(0).getAttribute("data-usd")


          image






          share|improve this answer
























          • Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

            – BOB
            Nov 23 '18 at 12:54











          • If I want to extract "$4,329.61" how can I do? Because it's a little bit different

            – BOB
            Nov 23 '18 at 13:00






          • 1





            @BOB You can use .innerText for that.

            – iBug
            Nov 23 '18 at 13:29


















          2














          You're getting a collection of HTML nodes with your query. You should try a more specific one and also getting its attributes:



          MsgBox objIE.document.QuerySelectorAll("a[href='/currencies/bitcoin/#markets']").Item(0).getAttribute("data-usd")


          image






          share|improve this answer
























          • Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

            – BOB
            Nov 23 '18 at 12:54











          • If I want to extract "$4,329.61" how can I do? Because it's a little bit different

            – BOB
            Nov 23 '18 at 13:00






          • 1





            @BOB You can use .innerText for that.

            – iBug
            Nov 23 '18 at 13:29
















          2












          2








          2







          You're getting a collection of HTML nodes with your query. You should try a more specific one and also getting its attributes:



          MsgBox objIE.document.QuerySelectorAll("a[href='/currencies/bitcoin/#markets']").Item(0).getAttribute("data-usd")


          image






          share|improve this answer













          You're getting a collection of HTML nodes with your query. You should try a more specific one and also getting its attributes:



          MsgBox objIE.document.QuerySelectorAll("a[href='/currencies/bitcoin/#markets']").Item(0).getAttribute("data-usd")


          image







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 12:33









          iBugiBug

          19k53362




          19k53362













          • Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

            – BOB
            Nov 23 '18 at 12:54











          • If I want to extract "$4,329.61" how can I do? Because it's a little bit different

            – BOB
            Nov 23 '18 at 13:00






          • 1





            @BOB You can use .innerText for that.

            – iBug
            Nov 23 '18 at 13:29





















          • Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

            – BOB
            Nov 23 '18 at 12:54











          • If I want to extract "$4,329.61" how can I do? Because it's a little bit different

            – BOB
            Nov 23 '18 at 13:00






          • 1





            @BOB You can use .innerText for that.

            – iBug
            Nov 23 '18 at 13:29



















          Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

          – BOB
          Nov 23 '18 at 12:54





          Thanks iBug, I didn't know that in VBScript you can use CSSSelector. This is very usefull !

          – BOB
          Nov 23 '18 at 12:54













          If I want to extract "$4,329.61" how can I do? Because it's a little bit different

          – BOB
          Nov 23 '18 at 13:00





          If I want to extract "$4,329.61" how can I do? Because it's a little bit different

          – BOB
          Nov 23 '18 at 13:00




          1




          1





          @BOB You can use .innerText for that.

          – iBug
          Nov 23 '18 at 13:29







          @BOB You can use .innerText for that.

          – iBug
          Nov 23 '18 at 13:29















          1














          Since the row of the table has the id attribute set. You can get the text content of the cell this way:



          objIE.document.GetElementById("id-bitcoin").Cells(3).InnerText





          share|improve this answer
























          • It's working but where did you get "id-bitcoin" ?

            – BOB
            Nov 23 '18 at 13:09











          • I saw it <tr id="id-bitcoin" class="odd" role="row">

            – BOB
            Nov 23 '18 at 13:10
















          1














          Since the row of the table has the id attribute set. You can get the text content of the cell this way:



          objIE.document.GetElementById("id-bitcoin").Cells(3).InnerText





          share|improve this answer
























          • It's working but where did you get "id-bitcoin" ?

            – BOB
            Nov 23 '18 at 13:09











          • I saw it <tr id="id-bitcoin" class="odd" role="row">

            – BOB
            Nov 23 '18 at 13:10














          1












          1








          1







          Since the row of the table has the id attribute set. You can get the text content of the cell this way:



          objIE.document.GetElementById("id-bitcoin").Cells(3).InnerText





          share|improve this answer













          Since the row of the table has the id attribute set. You can get the text content of the cell this way:



          objIE.document.GetElementById("id-bitcoin").Cells(3).InnerText






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 13:03









          Regis DesrosiersRegis Desrosiers

          35719




          35719













          • It's working but where did you get "id-bitcoin" ?

            – BOB
            Nov 23 '18 at 13:09











          • I saw it <tr id="id-bitcoin" class="odd" role="row">

            – BOB
            Nov 23 '18 at 13:10



















          • It's working but where did you get "id-bitcoin" ?

            – BOB
            Nov 23 '18 at 13:09











          • I saw it <tr id="id-bitcoin" class="odd" role="row">

            – BOB
            Nov 23 '18 at 13:10

















          It's working but where did you get "id-bitcoin" ?

          – BOB
          Nov 23 '18 at 13:09





          It's working but where did you get "id-bitcoin" ?

          – BOB
          Nov 23 '18 at 13:09













          I saw it <tr id="id-bitcoin" class="odd" role="row">

          – BOB
          Nov 23 '18 at 13:10





          I saw it <tr id="id-bitcoin" class="odd" role="row">

          – BOB
          Nov 23 '18 at 13:10


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446261%2fhow-do-i-parse-a-webpage-using-html-tags-in-vbscript%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...