Exemplo n.º 1
0
 public static function getSrcSeedURL($btih)
 {
     return popgo_get_seed_url($btih);
 }
Exemplo n.º 2
0
/**
 * 解析 POPGO 的 HTML 页面,提取 link,btih,magnet,并自动生成 guid 等信息
 * 
 * @return array    成功返回数组,失败时会输出错误信息,并返回空数组
 */
function popgo_parse_html($content)
{
    require_once 'phpQuery/phpQuery.php';
    $dom = phpQuery::newDocumentHTML($content);
    if (!$dom) {
        LOGE("无法解析漫游页面,原始内容:" . $content);
        return array();
    }
    $ret = array();
    for ($i = 0; $i < $dom->find('#index_maintable tr')->length(); $i++) {
        $pubDate = $dom->find("#index_maintable tr")->eq($i)->find("td")->eq(1)->text();
        $title = $dom->find("#index_maintable tr")->eq($i)->find("td.inde_tab_seedname")->text();
        $magnet = $dom->find("#index_maintable tr")->eq($i)->find("td")->eq(9)->find("a")->attr("href");
        $link = $dom->find("#index_maintable tr")->eq($i)->find("td")->eq(3)->find("a")->attr("href");
        $btih = popgo_get_btih_from_link($link);
        /// 针对 pubDate 格式的一点调整
        $pubDate = '20' . substr($pubDate, 0, 8) . ' ' . substr($pubDate, 8);
        if (stripos($title, '置顶') !== FALSE) {
            continue;
        }
        if ($title == '') {
            continue;
        }
        $ret[] = array('title' => $title, 'magnet' => $magnet, 'link' => 'http://share.popgo.org' . $link, 'guid' => popgo_get_seed_url($btih), 'pubDate' => strtotime($pubDate), 'btih' => $btih);
    }
    return $ret;
}