From d34987f9c12804f273a346fa5f4ee3d19cefae66 Mon Sep 17 00:00:00 2001 From: Matt DeMoss Date: Sat, 23 Dec 2017 15:57:40 -0500 Subject: [PATCH 1/2] PC Gamer bridge initial commit with most read stories --- bridges/PcGamerBridge.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bridges/PcGamerBridge.php diff --git a/bridges/PcGamerBridge.php b/bridges/PcGamerBridge.php new file mode 100644 index 0000000..b6ebcdc --- /dev/null +++ b/bridges/PcGamerBridge.php @@ -0,0 +1,23 @@ +getURI(), 300); + $stories = $html->find('div#popularcontent li.most-popular-item'); + foreach ($stories as $element) { + $item['uri'] = $element->find('a', 0)->href; + $articleHtml = getSimpleHTMLDOMCached($item['uri']); + $item['title'] = $element->find('h4 a', 0)->plaintext; + $item['timestamp'] = strtotime($articleHtml->find('meta[name=pub_date]', 0)->content); + $item['content'] = $articleHtml->find('meta[name=description]', 0)->content; + $item['author'] = $articleHtml->find('a[itemprop=author]', 0)->plaintext; + $this->items[] = $item; + } + } +} From fbbcd02384eb8b997256b9994172ccbc429322cd Mon Sep 17 00:00:00 2001 From: Matt DeMoss Date: Sun, 24 Dec 2017 16:45:56 -0500 Subject: [PATCH 2/2] apply phpcbf for automatic style fixes --- bridges/PcGamerBridge.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bridges/PcGamerBridge.php b/bridges/PcGamerBridge.php index b6ebcdc..e0e55ce 100644 --- a/bridges/PcGamerBridge.php +++ b/bridges/PcGamerBridge.php @@ -1,23 +1,23 @@ getURI(), 300); - $stories = $html->find('div#popularcontent li.most-popular-item'); - foreach ($stories as $element) { - $item['uri'] = $element->find('a', 0)->href; - $articleHtml = getSimpleHTMLDOMCached($item['uri']); - $item['title'] = $element->find('h4 a', 0)->plaintext; - $item['timestamp'] = strtotime($articleHtml->find('meta[name=pub_date]', 0)->content); - $item['content'] = $articleHtml->find('meta[name=description]', 0)->content; - $item['author'] = $articleHtml->find('a[itemprop=author]', 0)->plaintext; - $this->items[] = $item; - } - } + public function collectData() + { + $html = getSimpleHTMLDOMCached($this->getURI(), 300); + $stories = $html->find('div#popularcontent li.most-popular-item'); + foreach ($stories as $element) { + $item['uri'] = $element->find('a', 0)->href; + $articleHtml = getSimpleHTMLDOMCached($item['uri']); + $item['title'] = $element->find('h4 a', 0)->plaintext; + $item['timestamp'] = strtotime($articleHtml->find('meta[name=pub_date]', 0)->content); + $item['content'] = $articleHtml->find('meta[name=description]', 0)->content; + $item['author'] = $articleHtml->find('a[itemprop=author]', 0)->plaintext; + $this->items[] = $item; + } + } }