-2

I have tried to use...

var thepath: PWideChar;
thepath := 'http://www.google.com/finance?tab=we'; 
ShellExecute(Self.Handle, 'Open', 'chrome', thepath, '', sw_MINIMIZE);

and I want to end up with answers (csv form) in an Excel spreadsheet.

I'll like to bring the results directly into my Delphi program (as strings, perhaps) for processing and display.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
John K
  • 1
  • 2

1 Answers1

1

Use a REST API.

The code part could not be simpler:

http://docwiki.embarcadero.com/RADStudio/Berlin/en/Tutorial:_Using_the_REST_Client_Library_to_Access_REST-based_Web_Services

Follow the instructions in the tutorial.
I could copy paste it all here, but it's a bit much.

Once you got that working make the following changes for stocks: (see: http://www.example-code.com/DelphiDll/rest_simple.asp)

BaseURL: dev.markitondemand.com/MODApis/Api/v2/Quote Change the parameter to:

parameter.name:= 'symbol'
parameter.value:= 'AAPL' //Apple whatever ticker you feel like.

I'm not sure if this particular site can return json data, but I know it does do xml in the following format:

<?xml version="1.0" encoding="utf-8" ?>
<StockQuote>
    <Status>SUCCESS</Status>
    <Name>Apple Inc</Name>
    <Symbol>AAPL</Symbol>
    <LastPrice>94.91</LastPrice>
    <Change>-2.91</Change>
    <ChangePercent>-2.9748517686</ChangePercent>
    <Timestamp>Thu Apr 28 15:17:03 UTC-04:00 2016</Timestamp>
    <MSDate>42488.6368402778</MSDate>
    <MarketCap>526236372530</MarketCap>
    <Volume>4965478</Volume>
    <ChangeYTD>105.26</ChangeYTD>
    <ChangePercentYTD>-9.8327949838</ChangePercentYTD>
    <High>97.88</High>
    <Low>94.88</Low>
    <Open>97.61</Open>
</StockQuote>
Johan
  • 74,508
  • 24
  • 191
  • 319
  • if you don't want to (or cannot) use Embarcadero's REST components, you can use any HTTP client component/library, such as from Indy, ICS, Synapse, WinInet/WinHTTP, libcurl, etc. – Remy Lebeau May 09 '16 at 19:12
  • I don't have access to the REST components as I only have the "Starter" version of XE7. I tried to use the Indy components therein but have not yet found the correct one for this purpose. – John K May 12 '16 at 23:11