Write the data in real time "in the listbox
How to write cycle code intercepting a particular string???????
· · · · · · · · · · · · · · · · · · · · ·
To capture the content of website
http://zx.caipiao.163.com/trend/11xuan5/? BeginPeriod=14092901 & amp; EndPeriod=14100875 & amp; SelectDate=4
View the web page source.. Find the following characteristics
The data in & lt; Tbody id="cpdata" & gt; Inside,,,
Each line of the format is: the issue (space) the lottery number
Example
14100718 10 08 04 03 01
The 14100719 01 07 11 10 02
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
......
CodePudding user response:
With regular expressionsCodePudding user response:
procedure TForm1. Cp163Click (Sender: TObject);
Var
Doc2: IHTMLDocument2;
Doc3: IHTMLDocument3;
ItableCollection emtCollection: IHTMLElementCollection;
Itable: IHTMLTABLE;
Emt: IHTMLElement;
Tabrow: IHTMLTableRow;
Tabsec: IHTMLTableSection;
I, J, K: integer;
Sid, s1, s2, s3, s4, s5, sText: string;
The begin
ListBox1. The Clear;
Doc2:=self. WebBrowser1. Document as IHTMLDocument2;
Doc3:=WebBrowser1. Document as IHTMLDocument3;
ItableCollection:=doc2. All. Tags (' table ') as IHTMLElementCollection;
For I:=0 to itableCollection. Do Length - 1
The begin
Itable:=itableCollection. Item (I, 0) as IHTMLTABLE;
Emt:=itable as IHTMLElement;
If emt. Id='chartsTable then
The begin
Emt:=itable. TBodies. Item (1, 0) as IHTMLElement;//tbody cpdata
Tabsec:=emt as IHTMLTableSection;
Tabsec. Rows. Length;
For J:=0 to tabsec. Rows. Do Length - 1
The begin
Tabrow:=tabsec. Rows. The item (J, 0) as IHTMLTableRow;
If tabrow. Cells. Length & lt; 10 then
The Continue;
Sid:=(tabrow. Cells. The item (0, 0) as IHTMLElement). The innerText;//14100718
S1:=(tabrow. Cells. The item (2, 0) as IHTMLElement). The innerText;//01
S2:=(tabrow. Cells. The item (3, 0) as IHTMLElement). The innerText;//02
S3:=(tabrow. Cells. Item (4, 0) as IHTMLElement). The innerText;//3
S4:=(tabrow. Cells. The item (5, 0) as IHTMLElement). The innerText;//4
S5:=(tabrow. Cells. The item (6, 0) as IHTMLElement). The innerText;//05
SText:=Format (' % s % s % s % s % s % s', [the sid, s1, s2, s3, s4, s5]);
ListBox1. Items. The Add (sText);
The end;
The end;
The end;
The end;
CodePudding user response:
USES MSHTMLCodePudding user response:
This is ok?Thank ksrsoft teacher/
CodePudding user response:
Open a web page you willThe complete look here,
http://www.cnblogs.com/cb168/p/4012540.html
I tested, listbox data correctly
CodePudding user response:
After his added USES MSHTML, compile... Program stop hereDoc2:=self. WebBrowser1. Document as IHTMLDocument2;
WebBrowser1
CodePudding user response:
Appear this mistake.[Error] Unit1. Pas (41) : Undeclared identifier: 'WebBrowser1'
CodePudding user response:
Ksrsoft teacher is good, can complete Unit1. Pas code in your cnblogs?CodePudding user response:
You should put on your form a 'WebBrowser1 control.Put a listbox also
CodePudding user response: