Php webpage file reading problems

Source: Internet
Author: User
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
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.