update picoFeed to f3ed9fe and use icon from atom feeds as favicon

This commit is contained in:
Mathias Kresin 2015-01-18 15:20:36 +01:00
parent 1c68dd4727
commit 7c31b9fff0
20 changed files with 557 additions and 1379 deletions

View File

@ -29,12 +29,12 @@ function store_favicon($feed_id, $link, $icon)
}
// Download favicon
function fetch_favicon($feed_id, $site_url)
function fetch_favicon($feed_id, $site_url, $icon_link)
{
if (Config\get('favicons') == 1 && ! has_favicon($feed_id)) {
$favicon = new Favicon;
$link = $favicon->find($site_url);
$link = $favicon->find($site_url, $icon_link);
$icon = $favicon->getDataUri();
if ($icon !== '') {
@ -189,7 +189,7 @@ function create($url, $enable_grabber = false, $force_rtl = false)
$feed_id = $db->getConnection()->getLastId();
Item\update_all($feed_id, $feed->getItems());
fetch_favicon($feed_id, $feed->getSiteUrl());
fetch_favicon($feed_id, $feed->getSiteUrl(), $feed->getIcon());
Config\write_debug();
@ -261,7 +261,7 @@ function refresh($feed_id)
update_cache($feed_id, $resource->getLastModified(), $resource->getEtag());
Item\update_all($feed_id, $feed->getItems());
fetch_favicon($feed_id, $feed->getSiteUrl());
fetch_favicon($feed_id, $feed->getSiteUrl(), $feed->getIcon());
}
update_parsing_error($feed_id, 0);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca::getLoader();
return ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca
class ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -42,14 +42,14 @@ class ComposerAutoloaderInit1aea6e0e97930d7617e83f53a5287aca
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire1aea6e0e97930d7617e83f53a5287aca($file);
composerRequiredd123afa0ab8d569c051c35ab70311cb($file);
}
return $loader;
}
}
function composerRequire1aea6e0e97930d7617e83f53a5287aca($file)
function composerRequiredd123afa0ab8d569c051c35ab70311cb($file)
{
require $file;
}

View File

@ -162,12 +162,12 @@
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "d3785fc54d0bf9d521fd85e369cc5600f66099cc"
"reference": "f3ed9fef18b4cd0d25a1fd389c8a2e2370bcb51b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/d3785fc54d0bf9d521fd85e369cc5600f66099cc",
"reference": "d3785fc54d0bf9d521fd85e369cc5600f66099cc",
"reference": "f3ed9fef18b4cd0d25a1fd389c8a2e2370bcb51b",
"shasum": ""
},
"require": {

View File

@ -21,6 +21,21 @@ PicoFeed will try first to find the favicon from the meta tags and fallback to t
When the HTML page is parsed, relative links and protocol relative links are converted to absolute url.
Download a know favicon
-----------------------
It's possible to download a known favicon using the second optional parameter of Favicon::find(). The link to the favicon can be a relative or protocol relative url as well, but it has to be relative to the specified website.
If the requested favicon could not be found, the HTML of the website is parsed instead, with the fallback to the `favicon.ico` located in the website's root.
```php
use PicoFeed\Reader\Favicon;
$favicon = new Favicon;
$icon_link = $favicon->find('https://en.wikipedia.org/','https://bits.wikimedia.org/favicon/wikipedia.ico');
$icon_content = $favicon->getContent();
```
Get Favicon file type
---------------------

View File

@ -183,6 +183,7 @@ class Curl extends Client
curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'readHeaders'));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'php://memory');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'php://memory');
curl_setopt($ch, CURLOPT_SSLVERSION, 1); // Enforce TLS v1
$ch = $this->prepareProxyContext($ch);
$ch = $this->prepareAuthContext($ch);

View File

@ -171,6 +171,35 @@ class Grabber
return $this;
}
/**
* Get URL to download.
*
* @access public
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set URL to download and reset object to use for another grab.
*
* @access public
* @param string $url URL
* @return string
*/
public function setUrl($url)
{
$this->url = $url;
$this->html = "";
$this->content = "";
$this->encoding = "";
$this->handleFiles();
$this->handleStreamingVideos();
}
/**
* Get relevant content
*
@ -284,7 +313,7 @@ class Grabber
*/
public function download()
{
if (! $this->skip_processing) {
if (! $this->skip_processing && $this->url != '') {
try {

View File

@ -74,6 +74,18 @@ class Atom extends Parser
$feed->logo = (string) $xml->logo;
}
/**
* Find the feed icon
*
* @access public
* @param SimpleXMLElement $xml Feed xml
* @param \PicoFeed\Parser\Feed $feed Feed object
*/
public function findFeedIcon(SimpleXMLElement $xml, Feed $feed)
{
$feed->icon = (string) $xml->icon;
}
/**
* Find the feed title
*

View File

@ -75,13 +75,21 @@ class Feed
public $language = '';
/**
* Feed logo URL (not the same as icon)
* Feed logo URL
*
* @access public
* @var string
*/
public $logo = '';
/**
* Feed icon URL
*
* @access public
* @var string
*/
public $icon = '';
/**
* Return feed information
*
@ -140,6 +148,17 @@ class Feed
return $this->logo;
}
/**
* Get the icon url
*
* @access public
* $return string
*/
public function getIcon()
{
return $this->icon;
}
/**
* Get feed url
*

View File

@ -149,6 +149,7 @@ abstract class Parser
$this->findFeedId($xml, $feed);
$this->findFeedDate($xml, $feed);
$this->findFeedLogo($xml, $feed);
$this->findFeedIcon($xml, $feed);
foreach ($this->getItemsTree($xml) as $entry) {
@ -549,6 +550,15 @@ abstract class Parser
*/
public abstract function findFeedLogo(SimpleXMLElement $xml, Feed $feed);
/**
* Find the feed icon
*
* @access public
* @param SimpleXMLElement $xml Feed xml
* @param \PicoFeed\Parser\Feed $feed Feed object
*/
public abstract function findFeedIcon(SimpleXMLElement $xml, Feed $feed);
/**
* Get the path to the items XML tree
*

View File

@ -76,6 +76,18 @@ class Rss20 extends Parser
}
}
/**
* Find the feed icon
*
* @access public
* @param SimpleXMLElement $xml Feed xml
* @param \PicoFeed\Parser\Feed $feed Feed object
*/
public function findFeedIcon(SimpleXMLElement $xml, Feed $feed)
{
$feed->icon = '';
}
/**
* Find the feed title
*

View File

@ -157,17 +157,21 @@ class Favicon
*
* @access public
* @param string $website_link URL
* @param string $favicon_link optional URL
* @return string
*/
public function find($website_link)
public function find($website_link, $favicon_link = '')
{
$website = new Url($website_link);
$icons = $this->extract($this->download($website->getBaseUrl('/'))->getContent());
$icons[] = $website->getBaseUrl('/favicon.ico');
if ($favicon_link !== '') {
$icons = array($favicon_link);
} else {
$icons = $this->extract($this->download($website->getBaseUrl('/'))->getContent());
$icons[] = $website->getBaseUrl('/favicon.ico');
}
foreach ($icons as $icon_link) {
$icon_link = $this->convertLink($website, new Url($icon_link));
$resource = $this->download($icon_link);
$this->content = $resource->getContent();
@ -175,6 +179,8 @@ class Favicon
if ($this->content !== '') {
return $icon_link;
} elseif ($favicon_link !== '') {
return $this->find($website_link);
}
}

View File

@ -1,17 +1,20 @@
<?php
return array(
'test_url' => 'http://www.allgemeine-zeitung.de/lokales/polizei/zweimal-totalschaden-nach-unfaellen-auf-eisglatten-fahrbahnen-bei-mainz-und-bei-bad-sobernheim-mit-baeumen-kollidiert_14904737.htm',
'test_url' => 'http://www.allgemeine-zeitung.de/lokales/polizei/mainz-gonsenheim-unbekannte-rauben-esso-tankstelle-in-kurt-schumacher-strasse-aus_14913147.htm',
'body' => array(
'//div[contains(@class, "article")][1]',
),
'strip' => array(
'//read/h1',
'//*[@id="t-map"]',
'//*[contains(@class, "modules")]',
'//*[contains(@class, "adsense")]',
'//*[contains(@class, "linkbox")]',
'//*[contains(@class, "info")]',
'//*[@class="skip"]',
'//*[@class="funcs"]',
'//span[@class="nd address"]',
'//a[contains(@href, "abo-und-services")]'
)
);

View File

@ -36,6 +36,14 @@ class GrabberTest extends PHPUnit_Framework_TestCase
$this->assertTrue(is_array($grabber->getRules()));
}
// 01net.com - https://github.com/fguillot/miniflux/issues/267
public function testGetRules_afterRedirection()
{
$grabber = new Grabber('http://rss.feedsportal.com/c/629/f/502199/s/422f8c8a/sc/44/l/0L0S0A1net0N0Ceditorial0C640A3130Cces0E20A150Eimprimer0Eune0Epizza0Eet0Edes0Ebiscuits0Evideo0C0T0Dxtor0FRSS0E16/story01.htm');
$grabber->download();
$this->assertTrue(is_array($grabber->getRules()));
}
public function testGrabContent()
{
$grabber = new Grabber('http://www.egscomics.com/index.php?id=1690');

View File

@ -14,6 +14,10 @@ class FilterTest extends PHPUnit_Framework_TestCase
$expected = '<html><body><h1>boo</h1></body>';
$this->assertEquals($expected, Filter::stripHeadTags($input));
$input = file_get_contents('tests/fixtures/html4_page.html');
$expected = file_get_contents('tests/fixtures/html4_head_stripped_page.html');
$this->assertEquals($expected, Filter::stripHeadTags($input));
$input = file_get_contents('tests/fixtures/html_page.html');
$expected = file_get_contents('tests/fixtures/html_head_stripped_page.html');
$this->assertEquals($expected, Filter::stripHeadTags($input));

View File

@ -47,6 +47,17 @@ class AtomParserTest extends PHPUnit_Framework_TestCase
$this->assertEquals('http://www.bbc.co.uk/urdu/images/gel/rss_logo.gif', $feed->getLogo());
}
public function testFeedIcon()
{
$parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
$feed = $parser->execute();
$this->assertEquals('', $feed->getIcon());
$parser = new Atom(file_get_contents('tests/fixtures/lagrange.xml'));
$feed = $parser->execute();
$this->assertEquals('http://www.la-grange.net/favicon.png', $feed->getIcon());
}
public function testFeedUrl()
{
$parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));

View File

@ -11,137 +11,218 @@ class FaviconTest extends PHPUnit_Framework_TestCase
{
$favicon = new Favicon;
$html = '<!DOCTYPE html><html><head>
<link rel="shortcut icon" href="http://example.com/myicon.ico" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html));
$html = '<!DOCTYPE html><html><head>
<link rel="icon" href="http://example.com/myicon.ico" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html));
// multiple values in rel attribute
$html = '<!DOCTYPE html><html><head>
<link rel="shortcut icon" href="http://example.com/myicon.ico" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html));
// icon part of another string
$html = '<!DOCTYPE html><html><head>
<link rel="fluid-icon" href="http://example.com/myicon.ico" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html));
// with other attributes present
$html = '<!DOCTYPE html><html><head>
<link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/image.ico'), $favicon->extract($html));
// ignore icon in other attribute
$html = '<!DOCTYPE html><html><head>
<link type="icon" href="http://example.com/image.ico" />
</head><body><p>boo</p></body></html>';
// ignores apple icon
$html = '<!DOCTYPE html><html><head>
<link rel="apple-touch-icon" href="assets/img/touch-icon-iphone.png">
<link rel="icon" type="image/png" href="http://example.com/image.png" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/image.png'), $favicon->extract($html));
// allows multiple icons
$html = '<!DOCTYPE html><html><head>
<link rel="icon" type="image/gif" href="http://example.com/image.gif" />
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/image.gif'), $favicon->extract($html));
$html = '<!DOCTYPE html><html><head>
<link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/>
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/image.ico'), $favicon->extract($html));
$html = '<!DOCTYPE html><html><head>
<link rel="apple-touch-icon" href="assets/img/touch-icon-iphone.png">
<link rel="icon" type="image/png" href="http://example.com/image.png" />
<link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/>
</head><body><p>boo</p></body></html>';
$this->assertEquals(array('http://example.com/image.png', 'http://example.com/image.ico'), $favicon->extract($html));
// empty array with broken html
$html = '!DOCTYPE html html head
link rel="icon" type="image/png" href="http://example.com/image.png" /
link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/
/head body /p boo /p body /html';
$this->assertEquals(array(), $favicon->extract($html));
// empty array on no input
$this->assertEquals(array(), $favicon->extract(''));
// empty array on no icon found
$html = '<!DOCTYPE html><html><head>
</head><body><p>boo</p></body></html>';
$this->assertEquals(array(), $favicon->extract($html));
}
/*
public function testHasFile()
public function testExists()
{
$favicon = new Favicon;
$this->assertTrue($favicon->exists('https://en.wikipedia.org/favicon.ico'));
$this->assertFalse($favicon->exists('http://minicoders.com/favicon.ico'));
$this->assertFalse($favicon->exists('http://blabla'));
$this->assertFalse($favicon->exists(''));
}
*/
public function testConvertLink()
{
$favicon = new Favicon;
// relative link
$this->assertEquals(
'http://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('http://miniflux.net'), new Url('assets/img/favicon.png'))
);
// relative link + HTTPS
$this->assertEquals(
'https://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('assets/img/favicon.png'))
);
// absolute link
$this->assertEquals(
'http://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('http://miniflux.net'), new Url('/assets/img/favicon.png'))
);
// absolute link + HTTPS
$this->assertEquals(
'https://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('/assets/img/favicon.png'))
);
// Protocol relative link
$this->assertEquals(
'http://google.com/assets/img/favicon.png',
$favicon->convertLink(new Url('http://miniflux.net'), new Url('//google.com/assets/img/favicon.png'))
);
// Protocol relative link + HTTPS
$this->assertEquals(
'https://google.com/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('//google.com/assets/img/favicon.png'))
);
// URL same fqdn
$this->assertEquals(
'http://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('http://miniflux.net/assets/img/favicon.png'))
);
// URL different fqdn
$this->assertEquals(
'https://www.google.com/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('https://www.google.com/assets/img/favicon.png'))
);
// HTTPS URL
$this->assertEquals(
'https://miniflux.net/assets/img/favicon.png',
$favicon->convertLink(new Url('https://miniflux.net'), new Url('https://miniflux.net/assets/img/favicon.png'))
);
// empty string on missing website parameter
$this->assertEquals(
'',
$favicon->convertLink(new Url(''), new Url('favicon.png'))
);
// website only on missing icon parameter
$this->assertEquals(
'https://miniflux.net/',
$favicon->convertLink(new Url('https://miniflux.net'), new Url(''))
);
// empty string on missing website and icon parameter
$this->assertEquals(
'',
$favicon->convertLink(new Url(''), new Url(''))
);
}
public function testFind()
public function testFind_inMeta()
{
$favicon = new Favicon;
// Relative favicon in html
// favicon in meta
$this->assertEquals(
'http://miniflux.net/assets/img/favicon.png',
$favicon->find('http://miniflux.net')
);
$this->assertNotEmpty($favicon->getContent());
}
// Absolute html favicon
$this->assertEquals(
'http://php.net/favicon.ico',
$favicon->find('http://php.net/parse_url')
);
// public function testFind_inRootDir()
// {
// // favicon not in meta, only in website root (need example page)
// $favicon = new Favicon;
//
// $this->assertEquals(
// 'http://minicoders.com/favicon.ico',
// $favicon->find('http://minicoders.com')
// );
// }
$this->assertNotEmpty($favicon->getContent());
public function testFind_noIcons()
{
$favicon = new Favicon;
// Protocol relative favicon
$this->assertEquals(
'https://bits.wikimedia.org/favicon/wikipedia.ico',
$favicon->find('https://en.wikipedia.org/')
);
$this->assertNotEmpty($favicon->getContent());
// fluid-icon + https
$this->assertEquals(
'https://github.com/fluidicon.png',
$favicon->find('https://github.com')
);
$this->assertNotEmpty($favicon->getContent());
// favicon in meta
$this->assertEquals(
'http://www.microsoft.com/favicon.ico?v2',
$favicon->find('http://www.microsoft.com')
);
$this->assertNotEmpty($favicon->getContent());
// no icon
$this->assertEquals(
'',
$favicon->find('http://minicoders.com/favicon.ico')
$favicon->find('http://minicoders.com')
);
$this->assertEmpty($favicon->getContent());
}
public function testFind_directLinkFirst()
{
$favicon = new Favicon;
$this->assertEquals(
'http://miniflux.net/assets/img/touch-icon-ipad.png',
$favicon->find('http://miniflux.net', '/assets/img/touch-icon-ipad.png')
);
$this->assertNotEmpty($favicon->getContent());
}
public function testFind_fallsBackToExtract()
{
$favicon = new Favicon;
$this->assertEquals(
'http://miniflux.net/assets/img/favicon.png',
$favicon->find('http://miniflux.net','/nofavicon.ico')
);
$this->assertNotEmpty($favicon->getContent());
}
public function testDataUri()
{
$favicon = new Favicon;
@ -156,7 +237,7 @@ class FaviconTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $favicon->getDataUri());
}
public function testDataUriWithBadContentType()
public function testDataUri_withBadContentType()
{
$favicon = new Favicon;
$this->assertNotEmpty($favicon->find('http://www.lemonde.fr/'));

View File

@ -15,14 +15,21 @@ class ReaderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('https://google.com', $reader->prependScheme('https://google.com'));
}
public function testDownload()
public function testDownload_withHTTP()
{
$reader = new Reader;
$feed = $reader->download('http://wordpress.org/news/feed/')->getContent();
$this->assertNotEmpty($feed);
}
public function testDownloadWithCache()
public function testDownload_withHTTPS()
{
$reader = new Reader;
$feed = $reader->download('https://wordpress.org/news/feed/')->getContent();
$this->assertNotEmpty($feed);
}
public function testDownload_withCache()
{
$reader = new Reader;
$resource = $reader->download('http://linuxfr.org/robots.txt');
@ -78,30 +85,129 @@ class ReaderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('Rss20', $reader->detectFormat($content));
}
public function testFind()
public function testFind_rssFeed()
{
$reader = new Reader;
$resource = $reader->download('http://miniflux.net/');
$feeds = $reader->find($resource->getUrl(), $resource->getContent());
$this->assertTrue(is_array($feeds));
$this->assertNotEmpty($feeds);
$this->assertEquals('http://miniflux.net/feed', $feeds[0]);
$reader = new Reader;
$resource = $reader->download('http://www.bbc.com/news/');
$feeds = $reader->find($resource->getUrl(), $resource->getContent());
$this->assertTrue(is_array($feeds));
$this->assertNotEmpty($feeds);
$this->assertEquals('http://feeds.bbci.co.uk/news/rss.xml', $feeds[0]);
$html = '<!DOCTYPE html><html><head>
<link type="application/rss+xml" href="http://miniflux.net/feed">
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array('http://miniflux.net/feed'), $feeds);
}
public function testFind_atomFeed()
{
$reader = new Reader;
$resource = $reader->download('http://www.cnn.com/services/rss/');
$feeds = $reader->find($resource->getUrl(), $resource->getContent());
$this->assertTrue(is_array($feeds));
$this->assertNotEmpty($feeds);
$this->assertTrue(count($feeds) > 1);
$this->assertEquals('http://rss.cnn.com/rss/cnn_topstories.rss', $feeds[0]);
$this->assertEquals('http://rss.cnn.com/rss/cnn_world.rss', $feeds[1]);
$html = '<!DOCTYPE html><html><head>
<link type="application/atom+xml" href="http://miniflux.net/feed">
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array('http://miniflux.net/feed'), $feeds);
}
public function testFind_feedNotInHead()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head></head>
<body>
<link type="application/atom+xml" href="http://miniflux.net/feed">
<p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array('http://miniflux.net/feed'), $feeds);
}
public function testFind_noFeedPresent()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head>
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array(), $feeds);
}
public function testFind_ignoreUnknownType()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head>
<link type="application/flux+xml" href="http://miniflux.net/feed">
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array(), $feeds);
}
public function testFind_ignoreTypeInOtherAttribute()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head>
<link rel="application/rss+xml" href="http://miniflux.net/feed">
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array(), $feeds);
}
public function testFind_withOtherAttributesPresent()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://miniflux.net/feed">
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://miniflux.net/', $html);
$this->assertEquals(array('http://miniflux.net/feed'), $feeds);
}
public function testFind_multipleFeeds()
{
$reader = new Reader;
$html = '<!DOCTYPE html><html><head>
<link rel="alternate" type="application/rss+xml" title="CNN International: Top Stories" href="http://rss.cnn.com/rss/edition.rss"/>
<link rel="alternate" type="application/rss+xml" title="Connect The World" href="http://rss.cnn.com/rss/edition_connecttheworld.rss"/>
<link rel="alternate" type="application/rss+xml" title="World Sport" href="http://rss.cnn.com/rss/edition_worldsportblog.rss"/>
</head><body><p>boo</p></body></html>';
$feeds = $reader->find('http://www.cnn.com/services/rss/', $html);
$this->assertEquals(
array(
'http://rss.cnn.com/rss/edition.rss',
'http://rss.cnn.com/rss/edition_connecttheworld.rss',
'http://rss.cnn.com/rss/edition_worldsportblog.rss'
),
$feeds
);
}
public function testFind_withInvalidHTML()
{
$reader = new Reader;
$html = '!DOCTYPE html html head
link type="application/rss+xml" href="http://miniflux.net/feed"
/head body /p boo /p body /html';
$feeds = $reader->find('http://miniflux.net/', '');
$this->assertEquals(array(), $feeds);
}
public function testFind_withHtmlParamEmptyString()
{
$reader = new Reader;
$feeds = $reader->find('http://miniflux.net/', '');
$this->assertEquals(array(), $feeds);
}
public function testDiscover()

View File

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Un bilan des plantes génétiquement modifiées aux USA - Résumé d'un rapport américain - Afis - Association française pour l'information scientifique</title>
<meta name="Keywords" lang="fr" content="OGM, Afis, pseudo-sciences">
@ -10,7 +10,7 @@
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
@ -64,121 +64,121 @@
<a class="promo2" href="/boutique.html" style="background: url(squelettes/img/promo_abo.jpg) no-repeat;"></a>
</div>
</div>
<div id="menu_head">
<ul>
<li><a href="spip.php?rubrique11"><img src="squelettes/img/menu1.png" alt="Articles" ></a></li>
<li><a href="spip.php?rubrique14"><img src="squelettes/img/menu2.png" alt="Chroniques" ></a>
<div class="menu_raccord" style="width:120px;background:#E0AB27;"></div>
<ul class="menu2">
<li><a href="spip.php?rubrique47">Un monde fou, fou, fou...</a></li>
<li><a href="spip.php?rubrique24">Du côté de la science</a></li>
<li><a href="spip.php?rubrique53">Du côté de la recherche</a></li>
<li><a href="spip.php?rubrique26">Entre l&#8217;espoir et le faux-mage</a></li>
<li><a href="spip.php?rubrique16">Dialogue avec nos lecteurs</a></li>
</ul>
</li>
<li><a href="spip.php?rubrique8"><img src="squelettes/img/menu3.png" alt="Dossiers" ></a>
<div class="menu_raccord" style="width:109px;background:#36ABE0;"></div>
<ul class="menu3">
<li><a href="spip.php?rubrique60">Alimentation</a></li>
<li><a href="spip.php?rubrique30">Astrologie</a></li>
<li><a href="spip.php?rubrique39">Environnement</a></li>
<li><a href="spip.php?rubrique49">Homéopathie</a></li>
<li><a href="spip.php?rubrique32">Le créationnisme à visage découvert</a></li>
<li><a href="spip.php?rubrique29">Le Livre noir de la psychanalyse</a></li>
<li><a href="spip.php?rubrique57">Médicaments&nbsp;: à la recherche de lexpert indépendant</a></li>
<li><a href="spip.php?rubrique40">Nucléaire</a></li>
<li><a href="spip.php?rubrique38">OGM</a></li>
<li><a href="spip.php?rubrique55">Ondes électromagnétiques</a></li>
<li><a href="spip.php?rubrique33">Paranormal</a></li>
<li><a href="spip.php?rubrique56">Psychanalyse</a></li>
<li><a href="spip.php?rubrique34">Science et croyances&nbsp;: débat</a></li>
</ul>
</li>
<li><a href="spip.php?rubrique4"><img src="squelettes/img/menu4.png" alt="Livres et médias" ></a>
<div class="menu_raccord" style="width:151px;background:#CA123E;"></div>
<ul class="menu4">
<li><a href="spip.php?rubrique13">Notes de lecture</a></li>
<li><a href="spip.php?rubrique2">Dans les médias</a></li>
<li><a href="spip.php?rubrique25">Dans la presse sceptique</a></li>
<li><a href="spip.php?rubrique48">Sornettes sur Internet</a></li>
</ul>
</li>
<li><a href="spip.php?rubrique42"><img src="squelettes/img/menu5.png" alt="Tribunes" ></a>
<div class="menu_raccord" style="width:101px;background:#92A5BA;"></div>
<ul class="menu5">
<li><a href="spip.php?rubrique43">Science et croyances</a></li>
<li><a href="spip.php?rubrique44">OGM</a></li>
<li><a href="spip.php?rubrique45">Psychanalyse</a></li>
<li><a href="spip.php?rubrique54">Nucléaire</a></li>
</ul>
</li>
<li><a href="spip.php?rubrique15"><img src="squelettes/img/menu6.png" alt="La revue" ></a>
<div class="menu_raccord" style="width:103px;background:#4B4BA9;"></div>
<ul class="menu6">
<li><a href="spip.php?rubrique19">Éditoriaux</a></li>
<li><a href="spip.php?rubrique18">Sommaires</a></li>
<li><a href="spip.php?rubrique59">Presse</a></li>
<li><a href="spip.php?article25">Abonnements, adhésions, commandes</a></li>
</ul>
</li>
<li><a href="spip.php?rubrique17"><img src="squelettes/img/menu7.png" alt="L'AFIS" ></a>
<div class="menu_raccord" style="width:103px;background:#09559A;"></div>
<ul class="menu7">
<li><a href="spip.php?article65">Qui sommes-nous ?</a></li>
<li><a href="spip.php?rubrique35">Quest-ce que lAFIS&nbsp;?</a></li>
<li><a href="spip.php?rubrique3">Communiqués</a></li>
<li><a href="spip.php?rubrique23">Afis Infos</a></li>
<li><a href="spip.php?article868">Gouvernance</a></li>
<li><a href="spip.php?article761">Comités locaux</a></li>
<li><a href="agenda.html">Agenda</a></li>
</ul>
</li>
<li><a href="spip.php?article25"><img src="squelettes/img/menu8_bis.png" alt="Nous rejoindre!" width=192 height=25 style="margin-right:0;"></a></li>
</ul>
</div>
@ -186,19 +186,19 @@
<a href="http://www.pseudo-sciences.org"><img src="squelettes/img/home.png" style="padding-top:3px;" alt="Accueil" ></a>
<span class="navitxt">
<a href="http://www.pseudo-sciences.org">Accueil</a>
> <a href="spip.php?rubrique11" class="italic">Articles</a>
</span>
<form action="recherche.html" method="GET">
@ -206,7 +206,7 @@
<input id="searchbox" name="recherche" type="text" value="Rechercher" onfocus="if(this.value == 'Rechercher'){this.value='';}" onblur="if(!this.value){this.value='Rechercher';}">
</form> </div>
<!-- <p class="bold center" style="padding:5px;font-size:14px;"><span class="red">Dernière minute - </span><a class="blue" href="spip.php?article1762">Antennes
<!-- <p class="bold center" style="padding:5px;font-size:14px;"><span class="red">Dernière minute - </span><a class="blue" href="spip.php?article1762">Antennes
relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
@ -216,7 +216,7 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
<div id="art_main">
<div id="art_pretitre"></div>
<div id="art_print">
<a href="spip.php?page=imprimer&amp;id_article=2280" rel="nofollow" target="_blank" style="margin-right:5px;">
<img src="squelettes/img/print.gif" alt="Imprimer" title="Imprimer cet article"></a>
@ -224,13 +224,13 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-lang="fr">Tweeter</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
<div id="art_chapo" >
<div id="art_chapo" >
<h1>Un bilan des plantes génétiquement modifiées aux USA</h1>
<h2>Résumé d&#8217;un rapport américain</h2>
<p class="art_asd"></p>
<div style="clear:both;"></div>
</div>
<div class="texteencadre-spip spip">Nous publions ici, à titre dinformation, <strong>un résumé du rapport du Service des études économiques </strong> (Economic Research Service)<strong> du ministère américain de lagriculture </strong> (United States Department of Agriculture). Résumé rédigé par <strong>Louis-Marie Houdebine</strong>.
<p>La culture des plantes génétiquement modifiées (PGM) a commencé aux USA en 1996. Et ce pays compte aujourdhui, à lui seul, la moitié des PGM cultivées dans le monde. Un bilan économique de cette nouvelle technique de sélection génétique a été publié en février 2014. Il nous a semblé intéressant de porter à la connaissance ce document, afin daider nos lecteurs à se faire leur propre opinion sur un sujet controversé. En effet, si les OGM sont interdits à la culture en France (et dans plusieurs pays de lUnion Européenne), ils sont largement utilisés outre-Atlantique, et depuis près de deux décennies, ce qui permet une analyse <i>a posteriori</i>.</p>
@ -273,59 +273,59 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
<p>Une troisième génération de PGM est déjà une réalité et elle devrait prendre progressivement de limportance. Ces PGM ne sont pas destinées à lalimentation. Elles sont et seront productrices de biocarburants, de molécules dintérêt pharmaceutique, dhuiles industrielles, de fibres, de plastiques etc.</p>
</div>
<div id="art_menu"><div style="border:1px solid #CFCFCF;">
<div id="art_stats">Mis en ligne le 8 avril 2014<br>1116 visites</div>
<div id="art_themes" class="menubox">
<div class="cadre_top bleuclair_bcg"><img src="squelettes/img/titres/themes.png" alt="L'Auteur"></div>
<p class="center"><a class="bold" href="spip.php?mot165">OGM</a></p>
<ul>
<li><a href="spip.php?article2280" class="spip_in">Un bilan des plantes génétiquement modifiées aux USA</a></li>
<li><a href="spip.php?article991" class="spip_in">Les OGM&nbsp;: Menaces ou espoirs, données scientifiques</a></li>
<li><a href="spip.php?article2276" class="spip_in">Animal nutrition with transgenic plants</a></li>
<li><a href="spip.php?article784" class="spip_in">Que sont les OGM animaux&nbsp;?</a></li>
<li><a href="spip.php?article2275" class="spip_in">OGM, la question politique</a></li>
</ul>
</div>
<div id="art_abo" class="menubox">
<div class="cadre_top bleu_bcg"><img src="squelettes/img/titres/abonnezvous.png" alt="Abonnez vous"></div>
<p class="justify">Résultat de l'activité de bénévoles, lAFIS ne trouve ses ressources que dans les cotisations de ses adhérents et la vente de sa revue.</p>
<div class="cadre_top bleu_bcg"><img src="squelettes/img/titres/abonnezvous.png" alt="Abonnez vous"></div>
<p class="justify">Résultat de l'activité de bénévoles, lAFIS ne trouve ses ressources que dans les cotisations de ses adhérents et la vente de sa revue.</p>
<p class="justify">En vous abonnant, vous nous soutenez dans notre action tout en étant assuré de recevoir en premier notre revue trimestrielle dans votre boite aux lettres.</p>
<p class="center" style="font-weight:bold;"><a href="boutique.html">S'ABONNER</a></p>
</div>
</div></div>
</div></div>
<div style="clear:both;" class="art_fin"></div>
</div>
@ -334,117 +334,117 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
<div id="taglist" class="box" >
<p>Explorer par thème</p>
<ul>
<li><a href="spip.php?mot227">autisme</a></li>
<li><a href="spip.php?mot76">acupuncture</a></li>
<li><a href="spip.php?mot198">alimentation</a></li>
<li><a href="spip.php?mot30">astrologie</a></li>
<li><a href="spip.php?mot43">astronomie</a></li>
<li><a href="spip.php?mot197">biotechnologies</a></li>
<li><a href="spip.php?mot187">climat</a></li>
<li><a href="spip.php?mot48">cosmologie</a></li>
<li><a href="spip.php?mot75">créationnisme</a></li>
<li><a href="spip.php?mot145">croyance</a></li>
<li><a href="spip.php?mot23">désinformation</a></li>
<li><a href="spip.php?mot22">écologie</a></li>
<li><a href="spip.php?mot34">économie</a></li>
<li><a href="spip.php?mot40">éducation</a></li>
<li><a href="spip.php?mot59">éthique</a></li>
<li><a href="spip.php?mot189">évolution</a></li>
<li><a href="spip.php?mot208">expertise</a></li>
<li><a href="spip.php?mot31">graphologie</a></li>
<li><a href="spip.php?mot66">histoire</a></li>
<li><a href="spip.php?mot11">homéopathie</a></li>
<li><a href="spip.php?mot141">laïcité</a></li>
<li><a href="spip.php?mot52">littérature</a></li>
<li><a href="spip.php?mot69">mathématiques</a></li>
<li><a href="spip.php?mot9">médecine</a></li>
<li><a href="spip.php?mot27">mythes et légendes</a></li>
<li><a href="spip.php?mot33">neurologie</a></li>
<li><a href="spip.php?mot64">nucléaire</a></li>
<li><a href="spip.php?mot61">numérologie</a></li>
<li><a href="spip.php?mot165">OGM</a></li>
<li><a href="spip.php?mot201">ondes</a></li>
<li><a href="spip.php?mot13">ostéopathie</a></li>
<li><a href="spip.php?mot65">ovnis</a></li>
<li><a href="spip.php?mot42">paranormal</a></li>
<li><a href="spip.php?mot55">parapsychologie</a></li>
<li><a href="spip.php?mot49">philosophie</a></li>
<li><a href="spip.php?mot16">placebo</a></li>
<li><a href="spip.php?mot45">pseudoscience</a></li>
<li><a href="spip.php?mot7">psychanalyse</a></li>
<li><a href="spip.php?mot32">psychiatrie</a></li>
<li><a href="spip.php?mot8">psychologie</a></li>
<li><a href="spip.php?mot46">rationalisme</a></li>
<li><a href="spip.php?mot39">religion</a></li>
<li><a href="spip.php?mot6">santé</a></li>
<li><a href="spip.php?mot38">science</a></li>
<li><a href="spip.php?mot68">SVT</a></li>
<li><a href="spip.php?mot67">physique</a></li>
<li><a href="spip.php?mot50">sectes</a></li>
<li><a href="spip.php?mot57">sociologie</a></li>
<li><a href="spip.php?mot62">spiritisme</a></li>
<li><a href="spip.php?mot179">TCC</a></li>
<li><a href="spip.php?mot14">vaccination</a></li>
<li><a href="spip.php?mot60">voyance</a></li>
<li><a href="spip.php?mot47">zététique</a></li>
</ul>
<br>
</div>
<div id="footer">
<span class="float_left italic">Développé sous SPIP, logiciel libre </span>
<span class="float_right">
@ -455,7 +455,7 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
<a href="spip.php?article1096">Crédits</a>
</span>
</div>
</div>
<p id="w3c">
@ -473,7 +473,7 @@ relais et santé: des scientifiques répondent à l'ASEF</a></p> -->
_gaq.push(['_setAccount', 'UA-1826589-10']);
_gaq.push(['_trackPageview']);
(function() {
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

File diff suppressed because it is too large Load Diff