سلام
من یک چیزی ساختم برای خوندن آر اس اس
چطور میشه با پی اچ پی عکس های توی یک مورد مثلا مطلب رو هم بخونیم؟
سلام
من یک چیزی ساختم برای خوندن آر اس اس
چطور میشه با پی اچ پی عکس های توی یک مورد مثلا مطلب رو هم بخونیم؟
همون طور که مطالب و عنوانشونو میگیری از توی تگ IMAGE عکسشون رو هم parse کن.
کد HTML:<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>SoftArea51 - latest XML & CSS Utilities software for Windows</title> <link> http://www.softarea51.com/windows/Web_Development /XML_CSS_Utilities/LatestReleases-1.html </link> <description>Try and buy latest XML & CSS Utilities software for Windows</description> <language>en-us</language> <image> <title>SoftArea51 - latest XML & CSS Utilities software for Windows</title> <url>http://www.softarea51.com/images/logo.gif</url> <link>http://www.softarea51.com/</link> <description> Try and buy latest XML & CSS Utilities software for Windows </description> </image> <item> <title>Feed Mix</title> <link> http://www.softarea51.com/windows/Web_Development/ XML_CSS_Utilities/Review-Feed_Mix.html </link> <description> Feed Mix is a feature-rich RSS editor with the unique ability to create a new RSS feed from several others that already exist... </description> </item> <item> <title>RSS Submit</title> <link> http://www.softarea51.com/windows/Web_Development/ XML_CSS_Utilities/Review-RSS_Submit.html </link> <description> RSS Submit is the most powerful RSS feed promotion tool available... </description> </item> <item> <title>PAD-Script</title> <link> http://www.softarea51.com/windows/Web_Development/ XML_CSS_Utilities/Review-PAD_Script.html </link> <description> Avoid having to update all your PAD files whenever the PAD format changes... </description> </item> <item> <title>PAD Data Extractor Tool</title> <link> http://www.softarea51.com/windows/Web_Development/ XML_CSS_Utilities/Review-PAD_Data_Extractor_Tool.html </link> <description> Data Doctor XML PAD information extractor software tools extract important data from online website XML file... </description> </item> </channel> </rss>
ببین کدم رو اینطوری تغییر دادم.
همش کار میکنه ولی عکس رو بازم نمیخونه
<?php
$RSS_Content = array();
function RSS_Tags($item, $type)
{
$y = array();
$tnl = $item->getElementsByTagName("title");
$tnl = $tnl->item(0);
$title = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("link");
$tnl = $tnl->item(0);
$link = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("image");
$tnl = $tnl->item(0);
$image = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("description");
$tnl = $tnl->item(0);
$description = $tnl->firstChild->data;
$y["title"] = $title;
$y["link"] = $link;
$y["image"] = $image;
$y["description"] = $description;
$y["type"] = $type;
return $y;
}
function RSS_Channel($channel)
{
global $RSS_Content;
$items = $channel->getElementsByTagName("item");
// Processing channel
$y = RSS_Tags($channel, 0); // get description of channel, type 0
array_push($RSS_Content, $y);
// Processing articles
foreach($items as $item)
{
$y = RSS_Tags($item, 1); // get description of article, type 1
array_push($RSS_Content, $y);
}
}
function RSS_Retrieve($url)
{
global $RSS_Content;
$doc = new DOMDocument();
$doc->load($url);
$channels = $doc->getElementsByTagName("channel");
$RSS_Content = array();
foreach($channels as $channel)
{
RSS_Channel($channel);
}
}
function RSS_RetrieveLinks($url)
{
global $RSS_Content;
$doc = new DOMDocument();
$doc->load($url);
$channels = $doc->getElementsByTagName("channel");
$RSS_Content = array();
foreach($channels as $channel)
{
$items = $channel->getElementsByTagName("item");
foreach($items as $item)
{
$y = RSS_Tags($item, 1); // get description of article, type 1
array_push($RSS_Content, $y);
}
}
}
function RSS_Links($cat,$url, $size)
{
global $RSS_Content;
RSS_RetrieveLinks($url);
if($size > 0)
$recents = array_slice($RSS_Content, 0, $size);
foreach($recents as $article)
{
$type = $article["type"];
if($type == 0) continue;
$title = $article["title"];
$title = str_replace("'"," ",$title);
$title = trim ($title);
$link = $article["link"];
$image = $article["image"];
$desc = $article["description"];
$sit = explode('/',$link);
$site = $sit[2];
$sqk = mysql_query("select * from news where link = '$link' ") or die (mysql_error());
$nom = mysql_num_rows($sqk);
if($nom =='0') {
mysql_query("insert into news values('','$cat','$link','$title','$image') ") or die(mysql_error());
}
}
}
?>
مگه نباید تگ url اون image رو بخونیم؟ شما محتویات تگ image رو میخونید که خودش شامل یه سری تگ دیگه است...
میشه اون کد منو درست کنید!
فکر کنم توی تابع RSS_Tags، اون خط image رو اینجوری تغییر بدید درست شه:
$tnl = $item->getElementsByTagName("image");
$tnl = $tnl->item(0);
$tnl = $tnl->getElementsByTagName("url");
$tnl = $tnl->item(0);
$image = $tnl->data;
نشد! اینطوری هم کردم ولی باز نشد!
دوستان کسی نیست یک کمک کوچولو بکنه این کد منو تکمیل کنه تا عکس هم از آر اس اس بگیره؟
دوستان این برای من خیلی واجبه خواهشا اگه میتونید کمک کنید دریغ نکنید
خط آخر کد من رو اینجوری کن ببین میشه:
$image = $tnl->firstChild->data;
اگه نشد. این کد رو اجرا کن ببین مشکل کجاست:
print_r($image); print_r($tnl);
مورد اول رو که خودم از اول اجرا کردم نشد.
کلا نشد!
اقا یکی کمک کنه خیلی واجبه
دوست عزیز نمیخام توهین کنم ولی اینجا انحمن ی برای یادگیریه
اگه من بلد بودم چه لزومی داشت بپرسم؟
کسی نیست جواب بده؟