public static function parse_list($response) { $result = array(); $res = Text::parse_json($response); if (!isset($res["responseData"]["results"])) { throw new Exception("Invalid data"); } foreach ($res["responseData"]["results"] as $re) { $obj = new self(); $obj->location($re["location"]); $obj->publisher($re["publisher"]); $obj->url($re["unescapedUrl"]); $obj->title($re["titleNoFormatting"]); $obj->content($re["content"]); $obj->published($re["publishedDate"]); $result[] = $obj; } return $result; }
/** * Parse and HTML string. * * @param string $html - source of some HTML document * @param string $url - OPTIONAL location of the document. Used for relative URLs inside the document. * * @return hQuery $doc */ public static function fromHTML($html, $url = NULL) { $index_time = microtime(true); if (isset(self::$_mockup_class)) { $doc = new self::$_mockup_class($html, false); } else { $doc = new self($html, false); } if ($url) { $doc->location($url); } $doc->index(); $index_time = microtime(true) - $index_time; $doc->index_time = $index_time * 1000; return $doc; }