如何获得最新的沪深股票代码表呀?(200)

T

tswhq

Unregistered / Unconfirmed
GUEST, unregistred user!
1、读大智慧的,缺点:需要每天手工登录大智慧,太烦了2、读取网页的,例如:http://quote.eastmoney.com/stocklist.htmlunit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, SHDocVw,WinInet,mshtml;type TForm1 = class(TForm) WebBrowser: TWebBrowser; Memo1: TMemo; Button1: TButton; procedure Button1Click(Sender: TObject); procedure WebBrowserBeforeNavigate2(Sender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); procedure WebBrowserDocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); private { Private declarations } public { Public declarations } end;var Form1: TForm1; FirstDisp: IDispatch;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin WebBrowser.Navigate('http://quote.eastmoney.com/stocklist.html');end;procedure TForm1.WebBrowserBeforeNavigate2(Sender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool);begin FirstDisp:=pDisp;end;procedure TForm1.WebBrowserDocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);var i :integer; o :Variant;begin if FirstDisp<> pDisp then exit; beep; {for i:=0 to webbrowser.oleobject.document.links.length-1 do begin memo1.Lines.Add(webbrowser.oleobject.document.links.item(i).href); end;} for i :=0 to WebBrowser.OleObject.document.all.tags('li').Length-1 do Begin if pos('00',WebBrowser.OleObject.document.all.tags('li').item(i).InnerText)>0 then memo1.Lines.Add(WebBrowser.OleObject.document.all.tags('li').item(i).InnerText);//这个方法不保险,万一代码里没有00就惨了 end;仔细看了一下网页的源文件,股票的代码表放在这里<div class="quotebody">....</div>怎么读出来呢??? //WebBrowser.OleObject.Document.GetElementsByTagName('quotebody').InnerText; o:=WebBrowser.OleObject.document.getElementsByTagName('div'); memo1.Lines.Add(inttostr(o.length)); for i:=0 to o.length-1 do begin memo1.Lines.Add(o.item.caption)//这句不会,大家指点一下 end;end;end.
 
X

xianjun

Unregistered / Unconfirmed
GUEST, unregistred user!
只要代码表的话找个网站读网页就行了,这东西也不会经常变的,新股上市或有股退市才会增减而已。
 
A

allenzen

Unregistered / Unconfirmed
GUEST, unregistred user!
网页转XML,使用XPATH,一抓一个准
 
T

tswhq

Unregistered / Unconfirmed
GUEST, unregistred user!
网页转XML,使用XPATH,谁给一个例子看看
 
3

3868474

Unregistered / Unconfirmed
GUEST, unregistred user!
同花顺里面有个stocknametable.txt,里面有所有股票列表,也很容易读。
 
T

tswhq

Unregistered / Unconfirmed
GUEST, unregistred user!
你的思路是对的,我之前的代码就是读取大智慧的INIT.dat,问题是每天都要求登陆一次太烦了,同花顺也以一样呀!除非你能够模拟大智慧、同花顺的登陆,得到代码表,谁会呀?
 
Z

zhengct

Unregistered / Unconfirmed
GUEST, unregistred user!
登陆麻烦吗?自己用钩子模拟下也很容易吧,如果实是懒的话就按键小精灵解决了
 
Top Bottom