import requests
from bs4 import BeautifulSoup


def return_page_content(page_url):
    # Use haders to avoid being blocked
    hdr = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11'
        ' (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9'
        ',*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Encoding': 'none',
        'Accept-Language': 'en-US,en;q=0.8',
        'Connection': 'keep-alive'
    }
    try:
        req = requests.get(
            page_url, headers=hdr)
        return req.text
    except:
        raise


def return_rss(page_url):
    # inpired from quora post: bit.ly/1jGKdMY
    page_content = return_page_content(page_url)
    rss_link = ''
    soup = BeautifulSoup(page_content, "html.parser")
    link = soup.find('link', type='application/rss+xml')        
    if not link:
        raise Exception("The page has no RSS feed")
    rss_link = link.get('href')
    return rss_link

def return_atom(page_url):
    page_content = return_page_content(page_url)
    atom_link = ''
    soup = BeautifulSoup(page_content, "html.parser")
    link = soup.find('link',type='application/atom+xml')
        
    if not link:
        raise Exception("The page has no Atom feed")
    atom_link = link.get('href')
    return atom_link

@@ -40,16 +40,147 @@
 ulSoup%0A%0A
+class Grabfeed:%0A    rss = None%0A    atom = None%0A%0A    def __init__(self, rss, atom):%0A        self.rss = rss%0A        self.atom = atom%0A
 %0Adef ret
@@ -835,247 +835,60 @@
     
-# inpired from quora post: bit.ly/1jGKdMY%0A    page_content = return_page_content(page_url)%0A    rss_link = ''%0A    soup = BeautifulSoup(page_content, %22html.parser%22)%0A    link = soup.find('link', type='application/rss+xml')        %0A    if not 
+rss_link = return_feed(page_url).rss%0A    if not rss_
 link
@@ -945,40 +945,8 @@
 d%22)%0A
-    rss_link = link.get('href')%0A
     
@@ -985,24 +985,192 @@
 (page_url):%0A
+    atom_link = return_feed(page_url).atom%0A    if not atom_link:%0A        raise Exception(%22The page has no Atom feed%22)%0A    return atom_link%0A%0A%0Adef return_feed(page_url):%0A
     page_con
@@ -1283,16 +1283,21 @@
 r%22)%0A    
+atom_
 link = s
@@ -1361,16 +1361,21 @@
  if not 
+atom_
 link:%0A  
@@ -1384,69 +1384,222 @@
     
-raise Exception(%22The page has no Atom feed%22)%0A    atom
+atom_link = False%0A    else:%0A        atom_link = atom_link.get('href')%0A    rss_link = soup.find('link', type='application/rss+xml')        %0A    if not rss_link:%0A        rss_link = False%0A    else:%0A        rss
 _link = 
 link
@@ -1594,16 +1594,20 @@
 _link = 
+rss_
 link.get
@@ -1614,30 +1614,58 @@
 ('href')%0A    return 
+Grabfeed(rss=rss_link, atom=
 atom_link%0A
@@ -1655,17 +1655,18 @@
 , atom=atom_link
+)
 %0A

Return RSS and atom in single link