• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

请教php解析url的内容

php 搞代码 3年前 (2022-01-23) 5次浏览 已收录 0个评论
文章目录[隐藏]

请教各位,我有一个URL : http://help.ea.com/en/server-status/fifa-2016/
请教我如何把内容里 PC Game Servers ,Playstation 3 ,XBOX 360,XBOX One,Playstation 4这些属性下的UPDATED解析到?然后用PHP页面显示出来?

回复讨论(解决方案)

//$html 就是获取的页面 html$s = simple<b>%本文@来源gao@!dai!ma.com搞$$代^@码!网</b><strong>搞代gaodaima码</strong>xml_load_string($html);foreach($s->ul[0] as $li){	echo $li->h6[0].' - '.$li->p[0].'<br>';}/*PC Game Servers - Updated: 9:51 PM CST May, 15 Playstation 3 - Updated: 9:51 PM CST May, 15 XBOX 360 - Updated: 9:51 PM CST May, 15 XBOX One - Updated: 9:51 PM CST May, 15 Playstation 4 - Updated: 9:51 PM CST May, 15 */

//$html 就是获取的页面 html$s = simplexml_load_string($html);foreach($s->ul[0] as $li){	echo $li->h6[0].' - '.$li->p[0].'<br>';}/*PC Game Servers - Updated: 9:51 PM CST May, 15 Playstation 3 - Updated: 9:51 PM CST May, 15 XBOX 360 - Updated: 9:51 PM CST May, 15 XBOX One - Updated: 9:51 PM CST May, 15 Playstation 4 - Updated: 9:51 PM CST May, 15 */

能否给段完整的代码?我刚学PHP, 获取HTML内容没搞定我

//$html 就是获取的页面 html$s = simplexml_load_string($html);foreach($s->ul[0] as $li){	echo $li->h6[0].' - '.$li->p[0].'<br>';}/*PC Game Servers - Updated: 9:51 PM CST May, 15 Playstation 3 - Updated: 9:51 PM CST May, 15 XBOX 360 - Updated: 9:51 PM CST May, 15 XBOX One - Updated: 9:51 PM CST May, 15 Playstation 4 - Updated: 9:51 PM CST May, 15 */

能否给段完整的代码?我刚学PHP, 获取HTML内容没搞定我

$html= file_get_contents($url);

网站做了限制,你要打开这个网页查看它的cookie,并复制出来放在 $strCookie 中,我的cookie串就是下面 $strCookie的内容,改成你的就可以了

$strCookie = 'oauth_redirect=/en/server-status/fifa-2016/; PHPSESSID=nuqjjqj9aagnc8j2mglf82dj45; AWSELB=A32F41DF08C4BE7B7084C2525E0A6EA0DB38F970292F10DAB9FBCCA7735A84837B2C3A00FA5C83230EF9357A7A9E719B7CF0224072C74548F89DB34FEF6BDDBD0F640DAA52E77AC24ADCBD1AEEB365AA2D9CA5CA37';$url = 'http://help.ea.com/en/server-status/fifa-2016/';$html = mcurl($url,$strCookie); //紧接上面的代码//$s = simplexml_load_string($html);.....function mcurl($url,$strCookie) {    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $url);	curl_setopt($ch, CURLOPT_COOKIE, $strCookie);    $data = curl_exec($ch);    curl_close($ch);    return $data;}

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:请教php解析url的内容
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址