From e1056ce60855b0a6ece9f49ae5b96b6c9c52ab08 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 31 Jan 2019 21:09:58 +0100 Subject: Reading HtmlFeed user agent from config file --- providers/HtmlFeed.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'providers') diff --git a/providers/HtmlFeed.php b/providers/HtmlFeed.php index 411cddf..64d6259 100644 --- a/providers/HtmlFeed.php +++ b/providers/HtmlFeed.php @@ -7,10 +7,12 @@ require_once('../lib/querypath/src/qp.php'); abstract class HtmlFeed extends \Providers\XmlFeed { - const HTML_FEED_USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)'; - private $_encoding; + private function __getUserAgent() { + return trim(file_get_contents('../config/user-agent')); + } + private function __getHttpContent($feedUrl) { $header = array(); $header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; @@ -20,7 +22,7 @@ abstract class HtmlFeed extends \Providers\XmlFeed { $header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7'; $header[] = 'Pragma: '; $ch = curl_init($feedUrl); - curl_setopt($ch, CURLOPT_USERAGENT, self::HTML_FEED_USER_AGENT); + curl_setopt($ch, CURLOPT_USERAGENT, $this->__getUserAgent()); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -- cgit v1.2.3