当前位置: 首页>>代码示例>>PHP>>正文


PHP Blog::analyze_html方法代码示例

本文整理汇总了PHP中Blog::analyze_html方法的典型用法代码示例。如果您正苦于以下问题:PHP Blog::analyze_html方法的具体用法?PHP Blog::analyze_html怎么用?PHP Blog::analyze_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Blog的用法示例。


在下文中一共展示了Blog::analyze_html方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

	function get($url) {
		$url=trim($url);
		if(!preg_match('/^http[s]*:/', $url)) return false;
		$url_components = parse_url($url);
		if($url_components[host] == get_server_name()) return false;
		if(version_compare(phpversion(), '5.1.0') >= 0) {
			$opts = array(
				'http' => array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/) Gecko/Meneame Firefox', 'max_redirects' => 7),
				'https' => array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/) Gecko/Meneame Firefox', 'max_redirects' => 7)
			);
			$context = stream_context_create($opts);
			$url_ok = $this->html = file_get_contents($url, false, $context, 0, 200000);
		} else {
			$url_ok = $this->html = file_get_contents($url);
		}
		if (!$url_ok) return false;
		$this->valid = true;
		$this->url=$url;
		if(preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
			$this->encoding=trim($matches[1]);
			if(strcasecmp($this->encoding, 'utf-8') != 0) {
				$this->html=iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
			}
		}
		if(preg_match('/<title>([^<>]*)<\/title>/i', $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
		require_once(mnminclude.'blog.php');
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;

		// Detect trackbacks
		if (!empty($_POST['trackback'])) {
			$this->trackback=trim($_POST['trackback']);
		} elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) ||
			preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || 
			preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
			$this->trackback=trim($matches[1]);
		} elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		} elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		}  
		
	}
开发者ID:BackupTheBerlios,项目名称:meneamenet-svn,代码行数:54,代码来源:link.php

示例2: get

	function get($url) {
		$url=trim($url);
		//$context = array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/)'); // for PHP5
		if(!preg_match('/^http[s]*:/', $url) || !($this->html = file_get_contents($url))) {
			return;
		}
		$this->valid = true;
		$this->url=$url;
		if(preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
			$this->encoding=trim($matches[1]);
			if(strcasecmp($this->encoding, 'utf-8') != 0) {
				$this->html=iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
			}
		}
		if(preg_match('/<title>([^<>]*)<\/title>/i', $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
		require_once(mnminclude.'blog.php');
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;

		// Detect trackbacks
		if (!empty($_POST['trackback'])) {
			$this->trackback=trim($_POST['trackback']);
		} elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) ||
			preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || 
			preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
			$this->trackback=trim($matches[1]);
		} elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		} elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		}  
		
	}
开发者ID:BackupTheBerlios,项目名称:meneamenet-svn,代码行数:44,代码来源:link.php

示例3: Blog

	function create_blog_entry() {
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;
	}
开发者ID:rasomu,项目名称:chuza,代码行数:9,代码来源:link.php

示例4: Blog

 function create_blog_entry()
 {
     require_once mnminclude . 'blog.php';
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key')) {
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:11,代码来源:link.php

示例5: Blog

 function create_blog_entry()
 {
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key') || $blog->type != 'noiframe' && $this->noiframe) {
         if ($blog->type != 'noiframe' && $this->noiframe) {
             $blog->type = 'noiframe';
             syslog(LOG_INFO, "Meneame, changed to noiframe ({$blog->id}, {$blog->url})");
         }
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:14,代码来源:link.php

示例6: get

 function get($url)
 {
     $url = trim($url);
     if (Validate_URL != false) {
         $r = new HTTPRequest($url);
         $xxx = $r->DownloadToString();
     } else {
         $xxx = "";
         $this->valid = true;
         $this->url = $url;
         return;
     }
     if (CHECK_SPAM && $this->check_spam($url)) {
         $this->valid = false;
         return;
     }
     if (!($this->html = $xxx)) {
         return;
     }
     if ($xxx == "BADURL") {
         $this->valid = false;
         return;
     }
     $this->valid = true;
     $this->url = $url;
     if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
         $this->encoding = trim($matches[1]);
         //you need iconv to encode to utf-8
         if (function_exists("iconv")) {
             if (strcasecmp($this->encoding, 'utf-8') != 0) {
                 //convert the html code into utf-8 whatever encoding it is using
                 $this->html = iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
             }
         }
     }
     if (preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
         $this->url_title = trim($matches[1]);
     }
     require_once mnminclude . 'blog.php';
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key')) {
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
     // Detect trackbacks
     if (!empty($_POST['trackback'])) {
         $this->trackback = trim($_POST['trackback']);
     } elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) || preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
         $this->trackback = trim($matches[1]);
     } elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $this->trackback = trim($matches2[1]);
         }
     } elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\\/a>/i', $this->html, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $this->trackback = trim($matches2[1]);
         }
     }
 }
开发者ID:holsinger,项目名称:openfloor,代码行数:61,代码来源:link.php


注:本文中的Blog::analyze_html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。