コード例 #1
0
ファイル: Fc2.php プロジェクト: xzxzyzyz/laravel-crawler
 /**
  * DOMから有効なサムネイルを取得する
  * 有効な場合は画像のURLを返却する
  * 無効な場合は false を返却する
  *
  * @param  DOMDocument $dom
  * @return mixed
  */
 public function get($dom)
 {
     if ($dom->hasAttribute('width') && $dom->hasAttribute('height') && $dom->hasAttribute('alt') && !$dom->hasAttribute('title')) {
         $src = $dom->getAttribute('src');
         if (preg_match('/^http(s)?:\\/\\/blog-imgs-.*\\.fc2\\.com.*/', $src)) {
             return str_replace('-origin', '', $src);
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Ameba.php プロジェクト: xzxzyzyz/laravel-crawler
 /**
  * DOMから有効なサムネイルを取得する
  * 有効な場合は画像のURLを返却する
  * 無効な場合は false を返却する
  *
  * @param  DOMDocument $dom
  * @return mixed
  */
 public function get($dom)
 {
     if ($dom->hasAttribute('width') && $dom->hasAttribute('height') && $dom->hasAttribute('alt') && !$dom->hasAttribute('title')) {
         $src = $dom->getAttribute('src');
         if (preg_match('/^http(s)?:\\/\\/stat.*\\.ameba\\.jp.*/', $src)) {
             return $src;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: Livedoor.php プロジェクト: xzxzyzyz/laravel-crawler
 /**
  * DOMから有効なサムネイルを取得する
  * 有効な場合は画像のURLを返却する
  * 無効な場合は false を返却する
  *
  * @param  DOMDocument $dom
  * @return mixed
  */
 public function get($dom)
 {
     if ($dom->hasAttribute('class') && strpos($dom->getAttribute('class'), 'pict') === 0) {
         return $dom->getAttribute('src');
     }
     return false;
 }
コード例 #4
0
 /**
  * @param             $tag
  * @param             $propertyName
  * @param             $propertyValue
  * @param DOMDocument $node
  *
  * @return array
  */
 public function getElementsByProperty($tag, $propertyName, $propertyValue, $node = null)
 {
     $nodes = $node == null ? $this->getElementsByTagName($tag) : $node->getElementsByTagName($tag);
     $result = array();
     /** @var DOMElement $node */
     foreach ($nodes as $node) {
         if ($node->hasAttribute($propertyName)) {
             if ($node->getAttribute($propertyName) == $propertyValue) {
                 $result[] = $node;
             }
         }
     }
     return $result;
 }