[NextgovBridge] code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
03cbd756a6
commit
3fb8c5b916
1 changed files with 27 additions and 31 deletions
|
@ -44,16 +44,14 @@ class NextgovBridge extends BridgeAbstract {
|
|||
}
|
||||
|
||||
$category = $this->getInput('category');
|
||||
if (empty($category))
|
||||
$category = 'all';
|
||||
if ($category !== preg_replace('/[^a-z-]+/', '', $category) || strlen($category > 32))
|
||||
$this->returnClientError('Invalid "category" parameter.');
|
||||
$url = $this->getURI().'rss/'.$category.'/';
|
||||
$html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Nextgov: '.$url);
|
||||
$limit = 0;
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit < 10) {
|
||||
if ($limit >= 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
$article_url = ExtractFromDelimiters($element->innertext, '<link>', '</link>');
|
||||
$article_author = ExtractFromDelimiters($element->innertext, 'dc/elements/1.1/">', '</dc:creator>');
|
||||
|
@ -81,6 +79,4 @@ class NextgovBridge extends BridgeAbstract {
|
|||
$limit++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue