コード例 #1
0
ファイル: providers.php プロジェクト: hyungook/PHP-Crawler
 /**
  * Creating search item data
  * @param ContentAnalyzer $ca
  * @return type
  */
 public static function create_search_item(ContentAnalyzer $ca)
 {
     $desc = '';
     $meta = $ca->getMetaTags();
     if (isset($meta['description'])) {
         $desc = is_array($meta['description']) ? implode(' ', $meta['description']) : $meta['description'];
     }
     return db::create_fulltext_item($ca->getUrlId(), $ca->getTitle(), $desc, $ca->getPlainContent());
 }
コード例 #2
0
ファイル: providers.php プロジェクト: canaan5/verify-cr
 /**
  * Creating search item data
  * @param ContentAnalyzer $ca
  * @return type
  */
 public static function create_search_item(ContentAnalyzer $ca)
 {
     $desc = '';
     $meta = $ca->getMetaTags();
     $title = $ca->getTitle();
     $url = $ca->getUrl();
     if ($title == '') {
         $title = $ca->getOgTitle();
     }
     $content = $ca->getPlainContent();
     if ($content == '') {
         $content = $ca->getOgDescription();
     }
     if ($title == '') {
         return false;
     }
     if (isset($meta['description'])) {
         $desc = is_array($meta['description']) ? implode(' ', $meta['description']) : $meta['description'];
     }
     $host = parse_url($url)['host'];
     $keywords = self::create_keywords_from_content($content . ' ' . $title, $url);
     if (isset($meta['keywords']) && !empty($meta['keywords'])) {
         $keywords = is_array($meta['keywords']) ? implode(' ', $meta['keywords']) : $meta['keywords'];
     }
     if ($content == '' && $desc != '') {
         $content = $desc;
     }
     if (str_word_count($content) < 5) {
         return false;
     }
     if ($content == "") {
         return false;
     }
     if (strlen($content) != strlen(utf8_decode($content))) {
         return false;
     }
     return db::create_fulltext_item($title, $content, $keywords, $url, $desc);
 }