我目前正在使用Youtube刮刀从特定的视频(音乐封面)获得描述,并且这些描述有我需要的urls (例如,facebook/用户名)。现在,刮刀拉进了整个描述,然而,我所需要的只是Facebook链接。
有人能制造这样的铲运机吗?可能是一个“刮刀器”,我给它提供了10,000个Youtube视频URL,然后从这些URL中提取Facebook URL,并将它们粘贴到新行的文本文档中?
我在这里发现了一个与我需要做的非常相似的话题,但我只需要Facebook的URL。Save description of a number of youtube videos
发布于 2015-02-24 13:05:49
class Namespace_Youtubecrawler_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
//this $hashes array, populated by youtube_videos_only_hash.txt, contains youtube identifiers.
$hashes = array_unique(explode("\n", file_get_contents(Mage::getBaseDir('var') . DS . 'youtube_videos_only_hash.txt')));
foreach ($hashes as $hash) {
$json = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/videos/' . $hash . '?v=2&alt=json'), true);
$description = $json['entry']['media$group']['media$description']['$t'];
//if page contains bit.ly or pagesize with the description then the video's URL is logged in custom log file.
if ((strpos($description, 'pgsize') !== false) || (strpos($description, 'bit.ly') !== false)) {
$outdatedURL = 'http://www.youtube.com/watch?v=' . $hash;
Mage::log($outdatedURL, null, 'outdatedURLs.log', true);
}
}
}
}在我收集了一个url列表以供检查后,使用一些快捷的excel函数,我将这些url切碎到它们的组成标识符( youtube视频url末尾的散列对应于youtube上的“位置”)。
然后,我使用youtubes本机JSON编码页面(示例):
http://gdata.youtube.com/feeds/api/videos/oHg5SJYRHA0?v=2&alt=json&prettyprint=true
然后,上述内容将检查对某些参数的描述。我相信你可以很容易地修改它来识别facebook的网址。在找到参数之后,它重新组合youtube URL并将其记录下来(在本例中是在我们的服务器上)。
https://stackoverflow.com/questions/23106866
复制相似问题