如何编写一个汇率显示软件? 急!在线等。。。。(200)

Discussion in '电子商务' started by lb3141, Oct 22, 2010.

  1. lb

    lb3141 Member

    Apr 1, 2015
    只要能显示当天,昨天的汇率就ok,软件用delphi编写(单机版),我现在不知道如何获取汇率数据?是不是要访问web服务,如果是,访问接口是什么?
     
  2. ai

    aikede Member

    Apr 1, 2015
    直接去汇率网站抓取实时数据吧
     
  3. lb

    lb3141 Member

    Apr 1, 2015
    怎么抓取呀?
     
  4. lb

    lb3141 Member

    Apr 1, 2015
  5. sm

    smlabc Member

    Apr 1, 2015
    方案一,你去找银行,让他们给接口方案二,找几个网站,抓取网站内容
     
  6. lb

    lb3141 Member

    Apr 1, 2015
    方案一,你去找银行,让他们给接口 这个就算了方案二,怎么抓取
     
  7. zb

    zbdzjx Member

    Apr 1, 2015
    用webbrowser,顯示某個可以顯示匯率的網頁,再分析裏面的HTML腳本,讀出匯率就可以了。
     
  8. ai

    aikede Member

    Apr 1, 2015
    怎么抓,直接用 idhttp1.get(url);然后分析网页代码。。。。。。
     
  9. Ma

    Madara Member

    Apr 1, 2015
    可以用TCP协议直接连到网站上的80端口,发下URL请求报文的,然后就等网站服务器回数据了。偷懒的话用webbrowser也行,不过那个一用程序得大不少。
     
  10. xu

    xuxiaohan Member

    Apr 1, 2015
    用 MT4, 里面有DDE的实例 =MT4|BID!GBPUSD =MT4|ASK!GBPUSD =MT4|HIGH!GBPUSD =MT4|LOW!GBPUSD =MT4|TIME!GBPUSD
     
  11. 菜鸟黄

    菜鸟黄 Member

    Apr 1, 2015
    呵呵~看到你的问题,有点意思就写这东东给你吧unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, MSHTML, OleCtrls, SHDocVw, StrUtils, ExtCtrls;type TForm1 = class(TForm) ListView1: TListView;
    Button1: TButton;
    Memo1: TMemo;
    WebBrowser1: TWebBrowser;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    private { Private declarations } procedure MemoToLV(Memo: TMemo;
    ListView: TListView);
    public { Public declarations } end;
    var Form1: TForm1;
    LV_s: array [1..8] of string;implementation{$R *.dfm}procedure TForm1.MemoToLV(Memo: TMemo;
    ListView: TListView);var s: string;
    i,k: integer;
    begin
    ListView.Items.Clear;
    k := 1;
    for i:= 0 to Memo.Lines.Count-1do
    begin
    s := Trim(Memo.Lines.Strings);
    if s='<TR>' then
    begin
    with ListView.Items.Adddo
    begin
    Caption := LV_s[1];
    SubItems.Append(LV_s[2]);
    SubItems.Append(LV_s[3]);
    SubItems.Append(LV_s[4]);
    SubItems.Append(LV_s[5]);
    SubItems.Append(LV_s[6]);
    SubItems.Append(LV_s[7]);
    SubItems.Append(LV_s[8]);
    end;
    k := 1;
    end else
    begin
    LV_s[k] := s;
    inc(k);
    end;
    end;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    WebBrowser1.Navigate('http://www.boc.cn/sourcedb/whpj/');
    Timer1.Enabled := True;
    end;
    procedure TForm1.Timer1Timer(Sender: TObject);var k,k1: integer;
    s: string;
    begin
    try Memo1.Clear;
    s := IHtmlDocument2(WebBrowser1.Document).Body.outerHTML;
    k := pos('<TD class=nav bgColor=#ffffff vAlign=center width=86 align=middle>',s);
    k1 := pos('</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>',s);
    s := copy(s,k,k1-k);
    s := AnsiReplaceText(s, '<TD class=nav bgColor=#ffffff vAlign=center width=86 align=middle>', '');
    s := AnsiReplaceText(s, '</TD>', '');
    s := AnsiReplaceText(s, '</TR>', '')+#13#10+'<TR>';
    Memo1.Lines.Append(s);
    MemoToLV(Memo1,ListView1);
    Timer1.Enabled := False;
    except end;
    end;
    end.