Add w3m support
This commit is contained in:
35
inc/Feed.php
35
inc/Feed.php
@@ -35,20 +35,29 @@ class Feed extends PhpObject
|
|||||||
array_walk($asItems, array($this, 'addItem'));
|
array_walk($asItems, array($this, 'addItem'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadRss($sUrl)
|
public function loadRss($sUrl, $sMode='curl')
|
||||||
{
|
{
|
||||||
$oCurl = curl_init();
|
$sRssContent = '';
|
||||||
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
|
switch($sMode) {
|
||||||
curl_setopt($oCurl, CURLOPT_HEADER, false);
|
case 'curl':
|
||||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
$oCurl = curl_init();
|
||||||
curl_setopt($oCurl, CURLOPT_USERAGENT, array_key_exists('HTTP_USER_AGENT', $_SERVER)?$_SERVER['HTTP_USER_AGENT']:'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0');
|
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
|
||||||
$fCookieJar = @tempnam('/tmp','cookie');
|
curl_setopt($oCurl, CURLOPT_HEADER, false);
|
||||||
curl_setopt($oCurl, CURLOPT_COOKIESESSION, true);
|
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($oCurl, CURLOPT_COOKIEJAR, $fCookieJar);
|
curl_setopt($oCurl, CURLOPT_USERAGENT, array_key_exists('HTTP_USER_AGENT', $_SERVER)?$_SERVER['HTTP_USER_AGENT']:'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0');
|
||||||
curl_setopt($oCurl, CURLOPT_COOKIEFILE, $fCookieJar);
|
$fCookieJar = @tempnam('/tmp','cookie');
|
||||||
//curl_setopt($oCurl, CURLOPT_ENCODING, 'gzip');
|
curl_setopt($oCurl, CURLOPT_COOKIESESSION, true);
|
||||||
$sRssContent = curl_exec($oCurl);
|
curl_setopt($oCurl, CURLOPT_COOKIEJAR, $fCookieJar);
|
||||||
curl_close($oCurl);
|
curl_setopt($oCurl, CURLOPT_COOKIEFILE, $fCookieJar);
|
||||||
|
//curl_setopt($oCurl, CURLOPT_ENCODING, 'gzip');
|
||||||
|
$sRssContent = curl_exec($oCurl);
|
||||||
|
curl_close($oCurl);
|
||||||
|
break;
|
||||||
|
case 'w3m':
|
||||||
|
exec('w3m -dump '.$sUrl, $asOutput, $iResult);
|
||||||
|
$sRssContent = implode("\n", $asOutput);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//Parse document encoding (useless)
|
//Parse document encoding (useless)
|
||||||
$sEncoding = $this->getPregMatch("'encoding=[\'\"](.*?)[\'\"]'si", $sRssContent);
|
$sEncoding = $this->getPregMatch("'encoding=[\'\"](.*?)[\'\"]'si", $sRssContent);
|
||||||
|
|||||||
Reference in New Issue
Block a user