mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-05 21:43:55 +00:00
lint
This commit is contained in:
parent
d7f288fd72
commit
edca1b22eb
@ -1,39 +1,49 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PaulGrahamBridge extends BridgeAbstract {
|
class PaulGrahamBridge extends BridgeAbstract
|
||||||
|
{
|
||||||
const NAME = 'Paul Graham Essays';
|
const NAME = 'Paul Graham Essays';
|
||||||
const URI = 'https://www.paulgraham.com/articles.html';
|
const URI = 'https://www.paulgraham.com/articles.html';
|
||||||
const DESCRIPTION = 'Returns the latest Paul Graham essays in display order';
|
const DESCRIPTION = 'Returns the latest Paul Graham essays in display order';
|
||||||
const MAINTAINER = 'Claire (for Stéphane)';
|
const MAINTAINER = 'Claire (for Stéphane)';
|
||||||
const CACHE_TIMEOUT = 3600;
|
const CACHE_TIMEOUT = 3600;
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData()
|
||||||
|
{
|
||||||
$html = getSimpleHTMLDOM(self::URI);
|
$html = getSimpleHTMLDOM(self::URI);
|
||||||
|
|
||||||
// Navigate to the right TD
|
// Navigate to the right TD
|
||||||
// /html/body/table/tbody/tr/td[3]
|
// /html/body/table/tbody/tr/td[3]
|
||||||
$tables = $html->find('body table');
|
$tables = $html->find('body table');
|
||||||
if (!isset($tables[0])) return;
|
if (!isset($tables[0])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$tds = $tables[0]->find('td');
|
$tds = $tables[0]->find('td');
|
||||||
if (!isset($tds[2])) return;
|
if (!isset($tds[2])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$contentTd = $tds[2];
|
$contentTd = $tds[2];
|
||||||
|
|
||||||
// Find all inner tables (each one holds a single essay link)
|
// Find all inner tables (each one holds a single essay link)
|
||||||
$essayTables = $contentTd->find('table');
|
$essayTables = $contentTd->find('table');
|
||||||
if (!isset($essayTables[1])) return;
|
if (!isset($essayTables[1])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$essayTable = $essayTables[1];
|
$essayTable = $essayTables[1];
|
||||||
|
|
||||||
// /html/body/table/tbody/tr/td[3]/table[2]/tbody/tr[2]/td/font/a
|
|
||||||
|
|
||||||
$links = $essayTable->find('font');
|
// /html/body/table/tbody/tr/td[3]/table[2]/tbody/tr[2]/td/font/a
|
||||||
|
|
||||||
|
$links = $essayTable->find('font');
|
||||||
|
|
||||||
$essayLinks = [];
|
$essayLinks = [];
|
||||||
foreach ($links as $t) {
|
foreach ($links as $t) {
|
||||||
$link = $t->find('a', 0);
|
$link = $t->find('a', 0);
|
||||||
if (!$link) continue;
|
if (!$link) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$href = trim($link->href);
|
$href = trim($link->href);
|
||||||
$title = trim($link->plaintext);
|
$title = trim($link->plaintext);
|
||||||
|
Loading…
Reference in New Issue
Block a user