Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need some suggestion on a method to use

need some suggestion on a method to use

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcomtutorialquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benjamin yap
    wrote on last edited by
    #1

    Hi all, I got a txt file filled with HTML code extract from www.finance.yahoo.com this is the data from finance.yahoo.com Dow 10,212.73 +27.20 +0.27% Nasdaq 2,174.00 +2.80 +0.13% 10 Yr Bond(%) 3.6500% -0.0400 Oil 75.25 +0.82 +1.10% Gold 1,113.60 +10.10 +0.91 the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com. so, how should i create the method and what parameter should i pass in? should i create individual method for each stock? example double getDOW(param1, param2, param3, etc) or a generic method that can search any stock quote

    _ M D 3 Replies Last reply
    0
    • B benjamin yap

      Hi all, I got a txt file filled with HTML code extract from www.finance.yahoo.com this is the data from finance.yahoo.com Dow 10,212.73 +27.20 +0.27% Nasdaq 2,174.00 +2.80 +0.13% 10 Yr Bond(%) 3.6500% -0.0400 Oil 75.25 +0.82 +1.10% Gold 1,113.60 +10.10 +0.91 the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com. so, how should i create the method and what parameter should i pass in? should i create individual method for each stock? example double getDOW(param1, param2, param3, etc) or a generic method that can search any stock quote

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Use getline or CStdioFile to read the file line by line. Then use strtok_s or CString::Tokenize to extract the values from each line.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      1 Reply Last reply
      0
      • B benjamin yap

        Hi all, I got a txt file filled with HTML code extract from www.finance.yahoo.com this is the data from finance.yahoo.com Dow 10,212.73 +27.20 +0.27% Nasdaq 2,174.00 +2.80 +0.13% 10 Yr Bond(%) 3.6500% -0.0400 Oil 75.25 +0.82 +1.10% Gold 1,113.60 +10.10 +0.91 the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com. so, how should i create the method and what parameter should i pass in? should i create individual method for each stock? example double getDOW(param1, param2, param3, etc) or a generic method that can search any stock quote

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        You can have one method to read the "raw" data for each data line as long as they follow the same pattern, for example, in your case, it looks like: after that, you have to interpret each data like depending on where it comes from, is it from Dow ? is it from "Oil"? and decide if it's a percentage, a absolute value, a "delta" and put those values in the appropriate fields in your application : if ( == Dow ) { ... } else (if == Nasdaq ) { ... } ... Technically, there must be dozen different ways to do that, but I try to keep it as simple as possible. Good luck with that.

        This signature was proudly tested on animals.

        1 Reply Last reply
        0
        • B benjamin yap

          Hi all, I got a txt file filled with HTML code extract from www.finance.yahoo.com this is the data from finance.yahoo.com Dow 10,212.73 +27.20 +0.27% Nasdaq 2,174.00 +2.80 +0.13% 10 Yr Bond(%) 3.6500% -0.0400 Oil 75.25 +0.82 +1.10% Gold 1,113.60 +10.10 +0.91 the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com. so, how should i create the method and what parameter should i pass in? should i create individual method for each stock? example double getDOW(param1, param2, param3, etc) or a generic method that can search any stock quote

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          benjamin yap wrote:

          all the values need to be read from the HTML text file of finance.yahoo.com.

          Use the IHTMLDocument interface to navigate the HTML. Did you read this article suggested to you three days ago?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Man who follows car will be exhausted." - Confucius

          B 1 Reply Last reply
          0
          • D David Crow

            benjamin yap wrote:

            all the values need to be read from the HTML text file of finance.yahoo.com.

            Use the IHTMLDocument interface to navigate the HTML. Did you read this article suggested to you three days ago?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Man who follows car will be exhausted." - Confucius

            B Offline
            B Offline
            benjamin yap
            wrote on last edited by
            #5

            how do i extract 2,190.06 from here? <span class="streaming-datum" id="yfs_l10_^ixic">2,190.06</span> The ihtmldocument quite complicated to understand

            D 1 Reply Last reply
            0
            • B benjamin yap

              how do i extract 2,190.06 from here? <span class="streaming-datum" id="yfs_l10_^ixic">2,190.06</span> The ihtmldocument quite complicated to understand

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              benjamin yap wrote:

              how do i extract 2,190.06 from here?

              Look for a SPAN element named yfs_l10_^ixic. Then use one of the innerText, outerText, innerHTML, or outerHTML properties.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Man who follows car will be exhausted." - Confucius

              B 1 Reply Last reply
              0
              • D David Crow

                benjamin yap wrote:

                how do i extract 2,190.06 from here?

                Look for a SPAN element named yfs_l10_^ixic. Then use one of the innerText, outerText, innerHTML, or outerHTML properties.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Man who follows car will be exhausted." - Confucius

                B Offline
                B Offline
                benjamin yap
                wrote on last edited by
                #7

                do i have to #include anything to use the innertext, outertext etc etc?

                D 1 Reply Last reply
                0
                • B benjamin yap

                  do i have to #include anything to use the innertext, outertext etc etc?

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  They are methods of the IHTMLElement interface. You might need to include mshtml.h.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Man who follows car will be exhausted." - Confucius

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups