Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Scrapes single news item from screenrant
- *
- * @param string $url
- * @return string
- */
- public function getSingleFromFirstShowing($url)
- {
- $item = $this->curl($url);
- $crawler = new Crawler($item);
- $html = $crawler->filter('.review p')->each(function (Crawler $node, $i)
- {
- $ht = trim($node->html());
- //filter out unneeded html
- if (strpos($ht, 'class="technotags"')) return false;
- if (strpos($ht, 'title="Posts by')) return false;
- return '<p>' . preg_replace('/<a.*?>(.*?)<\/a>/', '$1', $ht) . '</p>';
- });
- return trim(implode('', $html));
- }
- /**
- * Scrapes single news item from screenrant
- *
- * @param string $url
- * @return string
- */
- public function getSingleFromScreenRant($url)
- {
- $text = '';
- $item = $this->curl($url);
- $crawler = new Crawler($item);
- $html = $crawler->filter('div[itemprop="articleBody"] p')->each(function (Crawler $node, $i)
- {
- $ht = trim($node->html());
- //filter out unneeded html
- if (strpos($ht, 'contentjumplink')) return false;
- if (strpos($ht, 'type="button"')) return false;
- if (strpos($ht, 'type="hidden"')) return false;
- if (strpos($ht, 'AD BLOCK')) return false;
- if (strpos($ht, 'src='))
- {
- preg_match('/.*?<img src="(.*?)"/', $ht, $m);
- if (isset($m[1]))
- {
- return "<img src='{$m[1]}' class='img-responsive'/>";
- }
- }
- return '<p>' . preg_replace('/<a.*?>(.*?)<\/a>/', '$1', $ht) . '</p>';
- });
- return trim(implode('', $html));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement