Skip to content

Commit 1d8c630

Browse files
committed
[CssSelectorBridge] Also support custom headers
So bridges extending this class can re-use the provided functions while supplying custom HTTP headers.
1 parent ea48084 commit 1d8c630

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bridges/CssSelectorBridge.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CssSelectorBridge extends BridgeAbstract
6565
]
6666
];
6767

68+
protected $headers = [];
6869
protected $feedName = '';
6970
protected $homepageUrl = '';
7071

@@ -97,7 +98,7 @@ public function collectData()
9798
$thumbnail_as_header = $this->getInput('thumbnail_as_header');
9899
$limit = $this->getInput('limit') ?? 10;
99100

100-
$html = defaultLinkTo(getSimpleHTMLDOM($this->homepageUrl), $this->homepageUrl);
101+
$html = defaultLinkTo(getSimpleHTMLDOM($this->homepageUrl, self::CACHE_TIMEOUT, $this->headers), $this->homepageUrl);
101102
$this->feedName = $this->titleCleanup($this->getPageTitle($html), $title_cleanup);
102103
$items = $this->htmlFindEntries($html, $url_selector, $url_pattern, $limit, $content_cleanup);
103104

@@ -154,7 +155,7 @@ protected function filterUrlList($links, $url_pattern, $limit = 0)
154155
protected function getPageTitle($page)
155156
{
156157
if (is_string($page)) {
157-
$page = getSimpleHTMLDOMCached($page);
158+
$page = getSimpleHTMLDOMCached($page, self::CACHE_TIMEOUT, $this->headers);
158159
}
159160
$title = html_entity_decode($page->find('title', 0)->plaintext);
160161
return $title;
@@ -211,7 +212,7 @@ protected function cleanArticleContent($content, $cleanup_selector)
211212
protected function htmlFindEntries($page, $url_selector, $url_pattern = '', $limit = 0, $content_cleanup = null)
212213
{
213214
if (is_string($page)) {
214-
$page = getSimpleHTMLDOM($page);
215+
$page = getSimpleHTMLDOM($page, self::CACHE_TIMEOUT, $this->headers);
215216
}
216217

217218
$links = $page->find($url_selector);
@@ -277,7 +278,7 @@ protected function expandEntryWithSelector($entry_url, $content_selector, $conte
277278
throwClientException('Please specify a content selector');
278279
}
279280

280-
$entry_html = getSimpleHTMLDOMCached($entry_url);
281+
$entry_html = getSimpleHTMLDOMCached($entry_url, self::CACHE_TIMEOUT, $this->headers);
281282
$item = html_find_seo_metadata($entry_html);
282283

283284
if (empty($item['uri'])) {

0 commit comments

Comments
 (0)