mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-05 17:19:37 +00:00
[GovTrackBridge] leaner items array and limit implementation
This commit is contained in:
parent
e039bd2d8d
commit
3740de74d5
@ -34,17 +34,18 @@ class GovTrackBridge extends BridgeAbstract
|
|||||||
|
|
||||||
$html = defaultLinkTo($html, parent::getURI());
|
$html = defaultLinkTo($html, parent::getURI());
|
||||||
$limit = $this->getInput('limit') ?? 10;
|
$limit = $this->getInput('limit') ?? 10;
|
||||||
$count = 0;
|
|
||||||
foreach ($html->find('section') as $element) {
|
foreach ($html->find('section') as $element) {
|
||||||
$item = [];
|
if (--$limit == 0) {
|
||||||
|
break;
|
||||||
$item['title'] = $element->find('a', 0)->innertext;
|
}
|
||||||
$item['uri'] = $element->find('a', 0)->href;
|
|
||||||
$item['content'] = $element->find('p', 1);
|
|
||||||
|
|
||||||
$info = explode(' ', $element->find('p', 0)->innertext);
|
$info = explode(' ', $element->find('p', 0)->innertext);
|
||||||
$item['timestamp'] = strtotime(implode(' ', array_slice($info, 0, 3)));
|
$item = [
|
||||||
$item['categories'][] = implode(' ', array_slice($info, 4));
|
'categories' => [implode(' ', array_slice($info, 4))],
|
||||||
|
'timestamp' => strtotime(implode(' ', array_slice($info, 0, 3))),
|
||||||
|
'title' => $element->find('a', 0)->innertext,
|
||||||
|
'uri' => $element->find('a', 0)->href,
|
||||||
|
];
|
||||||
|
|
||||||
$html = getSimpleHTMLDOMCached($item['uri']);
|
$html = getSimpleHTMLDOMCached($item['uri']);
|
||||||
$html = defaultLinkTo($html, parent::getURI());
|
$html = defaultLinkTo($html, parent::getURI());
|
||||||
@ -56,10 +57,6 @@ class GovTrackBridge extends BridgeAbstract
|
|||||||
$item['author'] = implode(' ', array_slice($info, 1));
|
$item['author'] = implode(' ', array_slice($info, 1));
|
||||||
$item['content'] = $content->innertext;
|
$item['content'] = $content->innertext;
|
||||||
|
|
||||||
if ($count++ == $limit) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,24 +81,25 @@ class GovTrackBridge extends BridgeAbstract
|
|||||||
$html = defaultLinkTo(str_get_html($html), parent::getURI());
|
$html = defaultLinkTo(str_get_html($html), parent::getURI());
|
||||||
|
|
||||||
foreach ($html->find('.tracked_event') as $event) {
|
foreach ($html->find('.tracked_event') as $event) {
|
||||||
$item = [];
|
|
||||||
|
|
||||||
$bill = $event->find('.event_title a, .event_body a', 0);
|
$bill = $event->find('.event_title a, .event_body a', 0);
|
||||||
preg_match('/Sponsor:(.*)\n/', $event->plaintext, $opt);
|
|
||||||
$date = explode(' ', $event->find('.event_date', 0)->plaintext);
|
$date = explode(' ', $event->find('.event_date', 0)->plaintext);
|
||||||
|
preg_match('/Sponsor:(.*)\n/', $event->plaintext, $opt);
|
||||||
|
|
||||||
$item['author'] = $opt[1] ?? '';
|
$item = [
|
||||||
$item['content'] = $event->find('td', 1)->innertext;
|
'author' => $opt[1] ?? '',
|
||||||
$item['enclosures'][] = $event->find('img', 0)->src;
|
'content' => $event->find('td', 1)->innertext,
|
||||||
$item['timestamp'] = strtotime(implode(' ', array_slice($date, 2)));
|
'enclosures' => [$event->find('img', 0)->src],
|
||||||
$item['title'] = explode(': ', $bill->innertext)[0];
|
'timestamp' => strtotime(implode(' ', array_slice($date, 2))),
|
||||||
$item['uri'] = $bill->href;
|
'title' => explode(': ', $bill->innertext)[0],
|
||||||
|
'uri' => $bill->href,
|
||||||
|
];
|
||||||
|
|
||||||
foreach ($event->find('.event_title, .event_type span') as $tag) {
|
foreach ($event->find('.event_title, .event_type span') as $tag) {
|
||||||
if (!$tag->find('a', 0)) {
|
if (!$tag->find('a', 0)) {
|
||||||
$item['categories'][] = $tag->plaintext;
|
$item['categories'][] = $tag->plaintext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user