Hi there I have a little problem that i need fixed as soon as possible.
I am the owner of an addon for the xbmc/kodi platform i have coded a php back end to help me find and add content but i am having a problem getting data from one of the sites i use
On the site there is a link from this link i need to get the href and some text from the title attribute
I can grab all the links on the page and go threw them and get the link i want i can then get the herf attribute but the problem i have is getting the title attribute and getting just the text i need from it
the html code for the link is below
<a title="Stream AMC- waliing dead Episode 12 No Ads and easy on - EasyPlayer" target="_blank" rel="nofollow" href="example.com/watch.php?id=64">EasyPlayer!</a>
from this link i can grab the href but not the title or the text i need from it
the only text i need is ( AMC- Walking dead ) this is dynamic and will change for every page i load
can someone help please i will post the code i have so far below
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$url = $_POST['url'];
$fanart = "http://feelgrafix.com/data_images/out/1/736215-anime-wallpaper.jpg";
$anime_thumbnail = "http://www.apkdad.com/wp-content/uploads/2013/01/Anime-Wallpapers-HD-Icon.png";
$plot = "Anime System by MetaBox HD IPTV";
$input = @file_get_contents($url) or die("Could not access file: $url");
$dom = new DOMDocument;
@$dom->loadHTML($input);
foreach($dom->getElementsByTagName('a') as $node) {
if(strpos($node->getAttribute('title'),'- EasyMode') !== false) {
$expires = preg_split('/Episode|episode/',$node->getAttribute('title'));
array_shift($expires);
$stream_url = $node->getAttribute('href');
$title_edit = str_replace(" Anime Series", "", $node->getAttribute('title'));
$title = str_replace("Watch ", "", $title_edit);
}
print_r($expires);
}
}
i need the out put of $anime_url to be the herf attribute
and i need the output of $title to be the text i need from the title attribute
thanks to anyone that can help
答案 0 :(得分:0)
我修复了这个问题我自己
通过查看视频流的标题我甚至抓住动态我发现有两个单词中的一个会出现各种各样的方式
否和|剧集
然后我只是使用一个爆炸函数将字符串拆分为eather字,然后使用replace函数删除剩余的单词(stream)
并且运行完整的东西抛出一个安全的函数来删除所有的html标签和特殊的字符
现在它完美无缺:)