I want to read some data from a web page by using php. The website is www. xjflcp. comservletsscflash? Typefull & amp; rand2266 my code is like this: $ urlwww. xjflcp. comservletsscflash? Typefull & amp; rand2266; $ doc & php
I want to read some data of a web page, the URL is: http://www.xjflcp.com/servlet/sscflash? Type = full/rand = 2266
My code is as follows:
$ Url = "http://www.xjflcp.com/servlet/sscflash? Type = fully & rand = 2266 ";
$ Doc = new DOMDocument ();
$ Doc-> load ($ url); // read the xml file
// $ Datas = $ doc-> saveXML ();
// $ Lst = $ doc-> getElementsByTagName ('history1 ');
// $ T1 = $ lst-> item (0)-> getElementsByTagName ("draw")-> item (0)-> nodeValue; // array of objects that obtain the name tag
// $ T1 = substr ($ t1, 2, 6). "0". substr ($ t1,-2 );
// $ T2 = $ lst-> item (0)-> getElementsByTagName ("prize_number")-> item (0)-> nodeValue; // array of objects that obtain the name tag
// $ T2 = str_replace ("|", $ t2 );
$ Lst = $ doc-> getElementsByTagName ('row ');
// For ($ I = 0; $ I <$ lst-> length; $ I ++ ){
For ($ I = 0; $ I <2; $ I ++ ){
$ Iframe = $ lst-> item ($ I );
$ T1 = $ iframe-> attributes-> getNamedItem ('draw')-> value;
$ T2 = $ iframe-> attributes-> getNamedItem ('prize _ number')-> value;
To obtain the second line
2014082856
1|4|0|9|5
57446
23
>
Draw and prize_number
------ Solution --------------------
$ Url = "http://www.xjflcp.com/servlet/sscflash? Type = fully & rand = 2266 ";
$ Doc = new DOMDocument ();
$ Doc-> load ($ url );
$ Recent_draws = $ doc-> getElementsByTagName ("recent_draw ");
$ Recent_draw = $ recent_draws-> item (0 );
$ Draw = getNodeVal ($ recent_draw, "draw ");
$ Prize_number = getNodeVal ($ recent_draw, "prize_number ");
Echo $ draw .'
';
Echo $ prize_number .'
';
Function getNodeVal (& $ myNode, $ tagName ){
Return $ myNode-> getElementsByTagName ($ tagName)-> item (0)-> nodeValue;
}
/*
2014082865
4
------ Solution --------------------
6
------ Solution --------------------
9
------ Solution --------------------
6
------ Solution --------------------
4
*/