本文整理汇总了PHP中Zend_Dom_Query::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Dom_Query::query方法的具体用法?PHP Zend_Dom_Query::query怎么用?PHP Zend_Dom_Query::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Dom_Query
的用法示例。
在下文中一共展示了Zend_Dom_Query::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertions
private function assertions($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->GetBody());
// comparing test xml with teh data from the xml from the file
// Asserting
// Assert - 1
$results1 = $dom->query('skos:notation');
$this->AssertEquals(1, count($results1));
$this->AssertEquals(self::$notation, $results1->current()->nodeValue);
// Assert - 2
$results2 = $dom->query('skos:inScheme');
$this->AssertEquals(1, count($results2));
$this->assertStringStartsWith("http://data.beeldengeluid.nl/gtaa/Onderwerpen", $results2->current()->getAttribute('rdf:resource'));
}
示例2: assertionsForXMLRDFCollection
private function assertionsForXMLRDFCollection($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$results1 = $dom->query('rdf:Description');
$collection_1_description_about = BASE_URI_ . '/api/collections/' . COLLECTION_1_tenant . ":" . COLLECTION_1_code;
$this->AssertEquals($collection_1_description_about, $results1->current()->getAttribute('rdf:about'));
$results2 = $dom->query('rdf:type');
$this->AssertEquals(COLLECTION_1_type_resource, $results2->current()->getAttribute('rdf:resource'));
$results3 = $dom->query('dcterms:title');
$this->AssertEquals(COLLECTION_1_title, $results3->current()->nodeValue);
$results4 = $dom->query('dcterms:creator');
$this->AssertEquals(COLLECTION_1_creator, $results4->current()->nodeValue);
$this->AssertEquals(COLLECTION_1_creator_about, $results4->current()->getAttribute('rdf:about'));
}
示例3: getContent
/**
* returns the content of this item
*
* @return string content
*/
public function getContent()
{
if ($this->items !== false && $this->valid()) {
try {
// load entry page
$client = new Zend_Http_Client($this->getLink() . '?page=all');
$response = $client->request();
$content = $response->getBody();
$content = utf8_decode($content);
// parse content
$dom = new Zend_Dom_Query($content);
$text = $dom->query('.article');
$innerHTML = '';
// convert innerHTML from DOM to string
// taken from http://us2.php.net/domelement (patrick smith)
$children = $text->current()->childNodes;
foreach ($children as $child) {
$tmp_doc = new DOMDocument();
$tmp_doc->appendChild($tmp_doc->importNode($child, true));
if (count($tmp_doc->getElementById('comments')) > 0) {
continue;
}
// convert to text
$innerHTML .= @$tmp_doc->saveHTML();
}
return $innerHTML;
} catch (Exception $e) {
// return default content
return current($this->items)->get_content();
}
}
}
示例4: _changeExternalLinks
protected static function _changeExternalLinks(&$content)
{
if (empty($content)) {
return;
}
$dom = new Zend_Dom_Query();
$dom->setDocumentHtml($content, 'utf-8');
if ($dom->getDocumentErrors()) {
return;
}
$query = $dom->query('.externalLink');
if (!$query->count()) {
return;
}
$links = array();
/** @var DOMElement $a */
foreach ($query as $a) {
$link = $a->getAttribute('href');
if (empty($link)) {
continue;
}
$links[] = $link;
GFNLinkProxy_Api::preload($link);
}
foreach ($links as $link) {
$content = preg_replace_callback('#(<a[^>]+href=("|\')?)(' . preg_quote($link, '#') . ')(("|\')?[^>]+class=("|\')?[^"\']*externalLink[^"\']*("|\')?[^>]*>)#sU', array(__CLASS__, '_replace'), $content, 1);
}
}
示例5: _findId
/**
* @desc find id
* @author makinder
* @param string|array $url;
* @version 0.0.1
*/
protected function _findId($urls)
{
if (!is_array($urls)) {
throw new Exception('url must be an array' . $urls);
}
foreach ($urls as $what => $url) {
$total_info = file_get_contents($url);
$dom = new Zend_Dom_Query($total_info);
$links = $dom->query('a');
$data = array();
foreach ($links as $item) {
$data[] = $item->getAttribute('href');
}
$find = '/title/tt';
$result = array();
foreach ($data as $index => $value) {
if (strpos($value, $find) !== false) {
$item = substr($value, strpos($value, '/tt') + 1, 9);
$result[] = $item;
}
}
$request = array();
$hoho[$what] = array_unique($result);
}
return $hoho;
}
示例6: getNewSizingChartContent
/**
* Get Sizing Chart content from remote resource
*/
public function getNewSizingChartContent($ptn)
{
if ($ptn) {
$uri = Mage::getStoreConfig('yk_config/asc/url') . $ptn;
$client = new Zend_Http_Client();
$client->setUri($uri);
$response = $client->request();
if ($html = $response->getBody()) {
$dom = new Zend_Dom_Query();
$dom->setDocumentHtml($html);
$results = $dom->query(Mage::getStoreConfig('yk_config/asc/container'));
if (count($results)) {
foreach ($results as $result) {
$innerHTML = '';
$children = $result->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveHTML($child);
}
return $innerHTML;
}
}
}
}
return false;
}
示例7: logIn
private function logIn()
{
$valuesLogin = array(new Oara_Curl_Parameter('username', $this->_credentials['user']), new Oara_Curl_Parameter('password', $this->_credentials['password']));
$cookies = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $this->_credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $this->_credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR . $this->_credentials["cookieName"] . '_cookies.txt';
unlink($cookies);
$this->_options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0", CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_COOKIEJAR => $cookies, CURLOPT_COOKIEFILE => $cookies, CURLOPT_HTTPAUTH => CURLAUTH_ANY, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0'), CURLOPT_ENCODING => "gzip", CURLOPT_VERBOSE => false);
$rch = curl_init();
$options = $this->_options;
curl_setopt($rch, CURLOPT_URL, "https://billing.purevpn.com/clientarea.php");
curl_setopt_array($rch, $options);
$html = curl_exec($rch);
curl_close($rch);
sleep(10);
$rch = curl_init();
$options = $this->_options;
curl_setopt($rch, CURLOPT_URL, "https://billing.purevpn.com/clientarea.php");
curl_setopt_array($rch, $options);
$html = curl_exec($rch);
curl_close($rch);
$dom = new Zend_Dom_Query($html);
$hidden = $dom->query('#frmlogin input[name="token"][type="hidden"]');
foreach ($hidden as $values) {
$valuesLogin[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
}
$rch = curl_init();
$options = $this->_options;
curl_setopt($rch, CURLOPT_URL, "https://billing.purevpn.com/dologin.php?goto=clientarea.php");
$options[CURLOPT_HTTPHEADER] = array('Referer: https://billing.purevpn.com/clientarea.php', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0');
$options[CURLOPT_POST] = true;
$arg = array();
foreach ($valuesLogin as $parameter) {
$arg[] = $parameter->getKey() . '=' . urlencode($parameter->getValue());
}
$options[CURLOPT_POSTFIELDS] = implode('&', $arg);
curl_setopt_array($rch, $options);
$html = curl_exec($rch);
curl_close($rch);
$rch = curl_init();
$options = $this->_options;
$options[CURLOPT_URL] = "https://billing.purevpn.com/check_affiliate.php?check=affiliate";
$options[CURLOPT_HEADER] = true;
$options[CURLOPT_NOBODY] = false;
$options[CURLOPT_HTTPHEADER] = array('Referer: https://billing.purevpn.com/affiliates.php', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0');
curl_setopt_array($rch, $options);
$header = curl_exec($rch);
preg_match('/Location:(.*?)\\n/', $header, $matches);
$newurl = trim(array_pop($matches));
curl_close($rch);
if (preg_match("/S=(.*)/", $newurl, $matches)) {
$this->_s = $matches[1];
}
$rch = curl_init();
$options = $this->_options;
$options[CURLOPT_URL] = $newurl;
$options[CURLOPT_HTTPHEADER] = array('Referer: https://billing.purevpn.com/affiliates.php', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0');
curl_setopt_array($rch, $options);
$content = curl_exec($rch);
}
示例8: task
public function task(Zend_Http_Response $response, Zend_Http_Client $client)
{
$query = new Zend_Dom_Query($response->getBody());
$images = $query->query('img');
foreach ($images as $image) {
$this->images[] = $image->getAttribute('src');
}
$this->images = array_unique($this->images);
}
示例9: getThumbnail
/**
* returns the thumbnail of this item (for multimedia feeds)
*
* @return mixed thumbnail data
*/
public function getThumbnail()
{
$item = current($this->items);
// allways take photo from content
$dom = new Zend_Dom_Query(@$item->get_content());
$imgTags = $dom->query('img');
if (count($imgTags)) {
return $imgTags->current()->getAttribute('src');
}
}
示例10: run
public function run()
{
if ($this->debugMode) {
echo "Restricting crawl to {$this->domain}\n";
}
//loop across available items in the queue of pages to crawl
while (!$this->queue->isEmpty()) {
if (isset($this->limit) && $this->counter >= $this->limit) {
break;
}
$this->counter++;
//get a new url to crawl
$url = $this->queue->pop();
if ($this->debugMode) {
echo "Queue Length: " . $this->queue->queueLength() . "\n";
echo "Crawling " . $url . "\n";
}
//set the url into the http client
$this->client->setUri($url);
//make the request to the remote server
$this->currentResponse = $this->client->request();
//don't bother trying to parse this if it's not text
if (stripos($this->currentResponse->getHeader('Content-type'), 'text') === false) {
continue;
}
//search for <a> tags in the document
$body = $this->currentResponse->getBody();
$linksQuery = new Zend_Dom_Query($body);
$links = $linksQuery->query('a');
if ($this->debugMode) {
echo "\tFound " . count($links) . " links...\n";
}
foreach ($links as $link) {
//get the href of the link and find out if it links to the current host
$href = $link->getAttribute('href');
$urlparts = parse_url($href);
if ($this->stayOnDomain && isset($urlparts["host"]) && $urlparts["host"] != $this->domain) {
continue;
}
//if it's an absolute link without a domain or a scheme, attempt to fix it
if (!isset($urlparts["host"])) {
$href = 'http://' . $this->domain . $href;
//this is a really naive way of doing this!
}
//push this link into the queue to be crawled
$this->queue->push($href);
}
//for each page that we see, run every registered task across it
foreach ($this->tasks as $task) {
$task->task($this->currentResponse, $this->client);
}
}
//after we're done with everything, call the shutdown hook on all the tasks
$this->shutdownTasks();
}
示例11: links
/**
* @description Searches for a line in the searcher
* @param string $lookIn
* @param string $searchString ('google','yandex','rambler','mail')
* @author makinder, Se#
* @version 0.0.2
* @changeLog
* 0.0.2 configurable urls
*/
public function links($resource, $string, $urls = array())
{
$urls = empty($urls) ? self::$urls : $urls;
$urls = self::insertString($urls, $string, '$string');
if (isset($urls[$resource])) {
$url = $urls[$resource];
} else {
return false;
}
$dom = new Zend_Dom_Query(file_get_contents($url));
return $dom->query('a');
}
示例12: getCaptcha
/**
* Gets captcha word
*
* @param string $html
* @return array
*/
public function getCaptcha($html)
{
$dom = new Zend_Dom_Query($html);
$id = $dom->query('#captcha-id')->current()->getAttribute('value');
foreach ($_SESSION as $key => $value) {
if (preg_match("/Zend_Form_Captcha_(.*)/", $key, $regs)) {
//if (ereg("Zend_Form_Captcha_(.*)", $key, $regs)) {
if ($regs[1] == $id) {
return array('id' => $id, 'input' => $value['word']);
}
}
}
}
示例13: checkConnection
/**
* Check the connection
*/
public function checkConnection()
{
//If not login properly the construct launch an exception
$connection = true;
$urls = array();
$urls[] = new Oara_Curl_Request('https://www.winneraffiliates.com/', array());
$exportReport = $this->_client->get($urls);
$dom = new Zend_Dom_Query($exportReport[0]);
$results = $dom->query('#lgUsername');
if (count($results) > 0) {
$connection = false;
}
return $connection;
}
示例14: deleteBasePathUrl
/**
* Removes the base path of the URL to HTML resources
*
* @param string $html
* @return string|bool If error, then output FALSE
*/
protected function deleteBasePathUrl($html)
{
//$domHtml
$str_begin = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<body>';
$str_end = '</body>';
//---------------------------
$filtrHtmlEntities = new Default_Form_Filter_HtmlEntities();
$html = $filtrHtmlEntities->filter($html);
$html = $str_begin . $html . $str_end;
// Check for correct XML
$domDoc = new DOMDocument('1.0', 'utf-8');
$success = $domDoc->loadXML($html);
if (!$success) {
return FALSE;
}
// Correct code
$domQuery = new Zend_Dom_Query();
$domQuery->setDocumentXml($html, "utf-8");
foreach (self::$tags as $tag => $attr) {
$results = $domQuery->query($tag);
if ($results->count()) {
foreach ($results as $result) {
// $result variable is of DOMElement type
if ($result->hasAttribute($attr)) {
$value = $result->getAttribute($attr);
$st = new Default_Plugin_String($value);
if ($st->beginsWith('/')) {
// it was: /zf-myblog/public/pic/1.gif
// it is: /pic/1.gif
$baseURL = Default_Plugin_SysBox::getBaseURL();
$value = str_replace($baseURL, '', $value);
$result->setAttribute($attr, $value);
} else {
// it was: https://mysite.com:8080/zf-myblog/public/pic/1.gif
// it is: /pic/1.gif
$hostPortBaseURL = Default_Plugin_SysBox::getHostPortBaseURL();
$value = str_replace($hostPortBaseURL, '', $value);
$result->setAttribute($attr, $value);
}
}
}
$domDoc = $results->getDocument();
$html = $domDoc->saveXml();
$domQuery->setDocumentXml($html, "utf-8");
}
}
$html = str_replace($str_begin, '', $html);
$html = str_replace($str_end, '', $html);
return $html;
}
示例15: parse_item
function parse_item($node, $defs, $fix)
{
$d = new DOMDocument();
$d->appendChild($d->importNode($node, TRUE));
$zend = new Zend_Dom_Query($d->saveHTML());
//debug($d->saveHTML());
$properties = array();
foreach ($defs->properties as $property => $def) {
if (is_string($def)) {
$def = (object) array('selector' => $def);
}
//debug($def);
if ($def->selector) {
$t = array();
foreach ($zend->query($def->selector) as $selected) {
$t[] = $selected;
}
$item = $t[0];
} else {
$item = $node;
}
if (!$item) {
continue;
}
if ($def->derived) {
$data = $properties[$def->derived];
} else {
$data = format($item, $def);
}
if (function_exists($fix)) {
$data = call_user_func($fix, $property, $data);
}
if ($def->date) {
$data = strtodate($def->date, $data);
}
$properties[$property] = $data;
}
if (!($properties['dc:identifier'] && $properties['dc:date'] && $properties['dc:title'])) {
return FALSE;
}
$properties['dc:identifier'] = base_url($properties['dc:identifier']);
if (!$properties['start']) {
$properties['start'] = strtotime($properties['dc:date']);
}
if (!$properties['end'] && is_numeric($properties['start'])) {
$properties['end'] = $properties['start'] + 3600;
}
// 1hr
return $properties;
}