标题:
关于金融街RSS制作人过程中出现的问题。
[打印本页]
作者:
龙听
时间:
2018-4-16 12:31
标题:
关于金融街RSS制作人过程中出现的问题。
这是我要做的订阅源:
http://futures.jrj.com.cn/list/ncpzx.shtml
这个是我写的RSS规则:
<?php
include "gethtml.php";
$regex_link = '#(?<=</i><a href="http://futures.jrj.com.cn/2018/).+?(?=")#';
$regex_tit = '#(?<=<title>).+?(?=-期货频道-金融界)#';
$regex_con = '#(?<=<!--内容 begin-->).*?(?=<!--内容 end-->)#';
$header='<?xml version="1.0" encoding="gb2312"?><rss version="2.0"><channel><title>农产品资讯-金融街</title>';
$footer='</channel></rss>';
$html=gethtml('http://futures.jrj.com.cn/list/ncpzx.shtml');
if(preg_match_all($regex_link, $html, $links)){
$size=10;
for($i=0;$i<$size;$i++){
$link='http://futures.jrj.com.cn/2018/'.$links[0][$i];
$content=gethtml($link);
preg_match($regex_con,$content,$article);
preg_match($regex_tit,$content,$title);
$rss.='<item><title>'.$title[0].'</title><link><![CDATA['.$link.']]></link><description><![CDATA['.$article[0].']]
></description></item>';
}
file_put_contents('agri.xml',$header.$rss.$footer);
}
?>
复制代码
(1)、我做的提取地址:
(?<=</i><a href="http://futures.jrj.com.cn/2018/).+?(?=")
复制代码
(2)、标题:
(?<=<title>).+?(?=-期货频道-金融界)
复制代码
(3)、内容:
(?<=<!--内容 begin-->).*?(?=<!--内容 end-->)#
复制代码
作者:
龙听
时间:
2018-4-16 12:34
现在出现的问题是提取的只有链接和标题。
欢迎光临 龙听期货论坛 (http://www.qhlt.cn/)
Powered by Discuz! 7.2