From f8eba128138322516f7ef831d3c5fc78c7135825 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Mon, 16 Oct 2017 20:08:24 -0400 Subject: fix fox, closes #12 --- unbiased/sources/fox.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/unbiased/sources/fox.py b/unbiased/sources/fox.py index ce7730f..573ddef 100644 --- a/unbiased/sources/fox.py +++ b/unbiased/sources/fox.py @@ -20,22 +20,16 @@ class Fox(NewsSource): """ soup = cls._fetch_content(cls.url) - # get primary headline - h1 = soup.find('div', id='big-top')\ - .find('div', class_='primary')\ - .find('h1')\ - .find('a')['href'] - h1s = (h1,) - - # get secondary headlines - h2s = soup.find('div', id='big-top').find('div', class_='top-stories').select('li > a') - h2s = tuple(x['href'] for x in h2s) - - # get tertiary headlines - h3s = [] - for ul in soup.find('section', id='latest').find_all('ul', recursive=False): - for li in ul.find_all('li', recursive=False): - h3s.append(li.find('a')['href']) - h3s = tuple(h3s) + + primary = soup.find('div', class_='main-primary')\ + .find('div', class_='collection-spotlight')\ + .find_all('article', class_='article') + h1s = (primary[0].find('header', class_='info-header').find('a')['href'],) + h2s = tuple(x.find('header', class_='info-header').find('a')['href'] for x in primary[1:]) + + h3s = soup.find('div', class_='main-primary')\ + .find('div', class_='collection-article-list')\ + .find_all('article', class_='article') + h3s = tuple(x.find('header', class_='info-header').find('h2', class_='title').find('a')['href'] for x in h3s) return h1s, h2s, h3s -- cgit v1.2.3