示例#1
0
 /**
  * Get all snippets for a given Yahoo SERP page.
  * @param  SimpleHtmlDom $SHDObject
  * @return array
  */
 protected function getPageSnippets($SHDObject)
 {
     $snippets = array();
     foreach ($SHDObject->find('.aAbs') as $object) {
         $snippetText = $this->cleanText($object->innertext);
         $snippets[] = $this->fixRepeatedSpace($snippetText);
     }
     // fetch only organic results
     return $this->normalizeResult($snippets);
 }
示例#2
0
 /**
  * Get all snippets for a given Bing SERP.
  * @param  SimpleHtmlDom $SHDObject
  * @return array
  */
 protected function getPageSnippets($SHDObject)
 {
     $snippets = array();
     // snippets in Bing's SERP are embedded into a <p> element child of b_caption
     foreach ($SHDObject->find('.b_caption p') as $object) {
         $snippetText = $this->cleanText($object->innertext);
         $snippets[] = $this->fixRepeatedSpace($snippetText);
     }
     // fetch only organic results
     return $this->normalizeResult($snippets);
 }
示例#3
0
 /**
  * Get all snippets for a given Google SERP.
  * @param  SimpleHtmlDom $SHDObject
  * @return array
  */
 protected function getPageSnippets($SHDObject)
 {
     $snippets = array();
     // snippets in Google's SERP are embedded into a <span> element with class "st"
     foreach ($SHDObject->find('.st') as $object) {
         $snippetText = $this->cleanText($object->innertext);
         $snippets[] = $this->fixRepeatedSpace($snippetText);
     }
     // fetch only organic results
     return $this->normalizeResult($snippets);
 }
示例#4
0
 public function set()
 {
     $data = file_get_contents('http://www.kongregate.com/contests?haref=hp_devcontest');
     $dom = new SimpleHtmlDom();
     $dom->load($data);
     $tables = [];
     $temp = [];
     foreach ($dom->find('table.contests') as $element) {
         foreach ($element->find('tr.js-game-hover') as $tr) {
             $temp[] = trim($tr->plaintext);
         }
         $tables[] = $temp;
         $temp = '';
     }
     $this->_DB->query('INSERT INTO contests (data, snap_date) VALUES (:data, :snap_date)');
     $this->_DB->bind(['data' => json_encode($tables), 'snap_date' => date('Y-m-d H:i:s')]);
     $this->_DB->execute();
     return $tables;
 }
示例#5
0
	public function pasteListAction() {
		$html = Redokes_Controller_Front::getInstance()->getParam('html', '');
		$parentId = intval(Redokes_Controller_Front::getInstance()->getParam('parentId', 0));
		$trackId = intval(Redokes_Controller_Front::getInstance()->getParam('trackId', 0));
		if ($trackId) {
			// check what kind of content was sent
			
			if (preg_match('/<ul|<ol/i', $html)) {
				// html list
				// convert any ol to ul
				$html = str_replace('<ol', '<ul', $html);
				$html = str_replace('</ol', '</ul', $html);

				// load up the html into a dom object
				$dom = new SimpleHtmlDom($html);
				$ul = $dom->find('>ul', 0);
				$this->makeFromUl($ul, $trackId, $parentId);
			}
			else if (preg_match('/[\n\r]/', $html)) {
				// multi line
				$this->makeFromNewLines($html, $trackId, $parentId);
			}
			else {
				// assume single line
				$this->makeFromNewLines($html, $trackId, $parentId);
			}
			return;
			
			$track = new Navigation_Model_Track($trackId);
			$track->clearCache();
		}
	}