From f1c846acd04388ece519f86c1788072add2c7f70 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 4 Jul 2020 00:27:15 +0000 Subject: [PATCH] Remove get first image --- apiserver/feed.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/apiserver/feed.py b/apiserver/feed.py index 8682309..f588972 100644 --- a/apiserver/feed.py +++ b/apiserver/feed.py @@ -56,19 +56,6 @@ def get_article(url): logging.error('Problem getting article: {}'.format(str(e))) return '' -def get_first_image(text): - soup = BeautifulSoup(text, features='html.parser') - - try: - first_img = soup.find('img') - url = first_img['src'] - headers = {'User-Agent': 'Twitterbot/1.0'} - length = requests.get(url, headers=headers, timeout=4).headers['content-length'] - if int(length) > 1000000: raise - return url - except: - return '' - def get_content_type(url): try: headers = {'User-Agent': 'Twitterbot/1.0'} @@ -130,8 +117,6 @@ def update_story(story, is_manual=False): story['text'] = get_article(story['url']) if not story['text']: return False - story['img'] = get_first_image(story['text']) - return True if __name__ == '__main__': @@ -147,7 +132,5 @@ if __name__ == '__main__': a = get_article('https://blog.joinmastodon.org/2019/10/mastodon-3.0/') print(a) - u = get_first_image(a) - print(u) print('done')