diff options
author | Matt Singleton <matt@xcolour.net> | 2017-10-16 20:08:24 -0400 |
---|---|---|
committer | Matt Singleton <matt@xcolour.net> | 2017-10-16 20:08:24 -0400 |
commit | f8eba128138322516f7ef831d3c5fc78c7135825 (patch) | |
tree | 61bd8f7de05f57cfc1c4aef4645be89d9b87f2c8 | |
parent | 78e9d2ac6d5132097af3f95913d9ff8ecbf56f7f (diff) |
fix fox, closes #12
-rw-r--r-- | unbiased/sources/fox.py | 28 |
1 files 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 |