Home > Back-end >  How to extract the show of things and the source code is the same address of data.
How to extract the show of things and the source code is the same address of data.

Time:09-26

If this http://hq.sinajs.cn/list=sh601006
Open display: var hq_str_sh601006="daqin railway, 11.22, 11.32, 11.32, 11.52, 10.52, 11.32, 11.33, 178528802198413 539409952,11.32, 11500,11.31, 26500,11.30, 11200,11.29, 790172,11.28, 117250,11.33, 312356,11.34, 269900,11.35, 102250,11.36, 144500,11.37, 2015-07-15, 15:03:04, 00";

Source: var hq_str_sh601006="daqin railway, 11.22, 11.32, 11.32, 11.52, 10.52, 11.32, 11.33, 178528802198413, 539409952,11.32, 11500,11.31, 26500,11.30, 11200,11.29, 790172,11.28, 117250,11.33, 312356,11.34, 269900,11.35, 102250,11.36, 144500,11.37, 2015-07-15, 15:03:04, 00";

Source code and open is the same with web,
This is a stock data, I want to extract,
I use the following code to extract source code display NULL
Public static void main (String [] args) {

String strUrl="http://hq.sinajs.cn/list=sh601006";
Try {
//create a url object to point to the site link in brackets () loading is the path of the web site links
//more can see http://wenku.baidu.com/view/8186caf4f61fb7360b4c6547.html
URL the URL=new URL (strUrl);
//InputStreamReader is an input stream reader used to read bytes into characters
//more can see http://blog.sina.com.cn/s/blog_44a05959010004il.html
InputStreamReader isr=new InputStreamReader (url. OpenStream (),
"Utf-8");//unified use utf-8 mode
//'re using the BufferedReader to read InputStreamReader converts characters
BufferedReader br=new BufferedReader (isr);
//if the content of the BufferedReader read isn't empty
While (br) readLine ()!=null) {
//print is printed here should be the result of the whole site
System. The out. Println (br) readLine ());
}
br.close();//read complete closed after the reader
} the catch (IOException e) {
//error if an exception is
e.printStackTrace();
}
}

Please will great god to give directions

CodePudding user response:

You are you using Delphi intercept? Extract the string?

CodePudding user response:

Done!!!!!!

CodePudding user response:

 function TFrmTip. GetGoodData () : Integer; 
Var
ReStr str_1: string;
Idhtp1: TIdHTTP;
LST, lst2: TStringList;
I, nPos: Integer;
The begin
Result:=0;
If FUrl="' then the Exit;

Try
Idhtp1:=TIdHTTP. Create (nil);
//'http://hq.sinajs.cn/list=s_sh600302, s_sz002313, s_sz300185'
ReStr:=idhtp1. Get (FUrl);

OutputDebugString (PChar (reStr));

If reStr="' then the Exit;
FList. The Clear ();
//'var hq_str_s_sh600302="standard, 8.86, 0.32, 3.75, 47130416 7"; '
//# $A 'var hq_str_s_sz002313="sea communications, 0.00, 0.00, 0.00, 0, 0"; '
//# $A 'var hq_str_s_sz300185="tong yu heavy industry, 10.240, 0.250, 2.50, 107719109, 74". '# $A
LST:=SplitString (reStr, '; ');
For I:=0 to LST. Do the Count - 1
The begin
NPos:=Pos ('=', LST [I]);
If nPos & lt; & gt; 0 then
The begin
Str_1:=Copy (LST [I], nPos + 2, 100);
//OutputDebugString (PChar (str_1));
Lst2:=SplitString (str_1, ', ');
FList. Add (Copy (lst2 [0], 1, 4) + "+ lst2 [1] + ' '+ lst2 [2]).
FreeAndNil (lst2);
The end;
The end;
FreeAndNil (LST);
Result:=FList. Count;
Except,
FreeAndNil (idhtp1);
The end;
If idhtp1 & lt; & gt; Nil then FreeAndNil (idhtp1);
The end;

CodePudding user response:

http://www.cnblogs.com/doorsky/p/4724737.html
  • Related