Home > Back-end >  About the web page source string intercept...
About the web page source string intercept...

Time:09-29

Want to write their own a lottery data update gadgets.
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,,,

' ' ' 'the issue is in the double colon






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 expressions

CodePudding 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 MSHTML

CodePudding user response:

This is ok?

Thank ksrsoft teacher/

CodePudding user response:

Open a web page you will
The 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 here

Doc2:=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:

references 9 f ksrsoft response:
you should put on your form a 'WebBrowser1 control.
Listbox also put a


Ksrsoft teacher good...
This time I added... And, after the success of the edit... Run, and an error

CodePudding user response:

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Project1
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Access violation at address 0045 e7fb module in 'Project1. Exe'. Read of address 00000000.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sure
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

You use what version, what I use is xe7
Note that there
WebBrowser1. Navigate (' http://zx.caipiao.163.com/trend/11xuan5/? BeginPeriod=14092901 & amp; EndPeriod=14100875 & amp; SelectDate=4 ');
While WebBrowser1. Busy do
Application. ProcessMessages;
.
Open the document, such as load to perform at the back of the statement
Behind the document not finish loading executive complains

CodePudding user response:

My is Delphi 7

Is the loading time is too long?

CodePudding user response:

Cb Daniel came to Delphi rob points on the nullnullnullnullnullnullnullnullnullnullnull
  • Related