app/request.py
def map_articles_results(headlines_results):
  '''
  map articles results to a list of article objects

  Args:
      List of articles from the payload

  Returns:
        A list of articles objects
  '''
  headlines_list=[]
  for headline in headlines_results:
    source_id=headline.get('source').get('id')
    source_name=headline.get('source').get('name')
    author=headline.get('author')
    title=headline.get('title')
    description=headline.get('description')
    url=headline.get('url')
    image_url=headline.get('urlToImage')
    publication_date=headline.get('publishedAt')
    content=headline.get('content')
    pub_date=isoparse(publication_date)
    pub_date.astimezone(UTC)
    converted_publication_date=pub_date.strftime("%b %d, %Y %H:%M:%S")
    
    if content:
      headline_object=Article(source_id,source_name,author,title,description,url,image_url,converted_publication_date,content)
      headlines_list.append(headline_object)

  return headlines_list

  map articles results to a list of article objects

  Args:
      List of articles from the payload

  Returns:
        A list of articles objects
  
map articles results to a list of article objects
Args:
List of articles from the payload

A list of articles objects
map articles results to a list of article objects Args : List of articles from the payload A list of articles objects
def map_articles_results(headlines_results):
  headlines_list=[]
  for headline in headlines_results:
    source_id=headline.get('source').get('id')
    source_name=headline.get('source').get('name')
    author=headline.get('author')
    title=headline.get('title')
    description=headline.get('description')
    url=headline.get('url')
    image_url=headline.get('urlToImage')
    publication_date=headline.get('publishedAt')
    content=headline.get('content')
    pub_date=isoparse(publication_date)
    pub_date.astimezone(UTC)
    converted_publication_date=pub_date.strftime("%b %d, %Y %H:%M:%S")
    if content:
      headline_object=Article(source_id,source_name,author,title,description,url,image_url,converted_publication_date,content)
      headlines_list.append(headline_object)
  return headlines_list
def map_articles_results ( headlines_results ) : headlines_list = [ ] for headline in headlines_results : source_id = headline . get ( 'source' ) . get ( 'id' ) source_name = headline . get ( 'source' ) . get ( 'name' ) author = headline . get ( 'author' ) title = headline . get ( 'title' ) description = headline . get ( 'description' ) url = headline . get ( 'url' ) image_url = headline . get ( 'urlToImage' ) publication_date = headline . get ( 'publishedAt' ) content = headline . get ( 'content' ) pub_date = isoparse ( publication_date ) pub_date . astimezone ( UTC ) converted_publication_date = pub_date . strftime ( "%b %d, %Y %H:%M:%S" ) if content : headline_object = Article ( source_id , source_name , author , title , description , url , image_url , converted_publication_date , content ) headlines_list . append ( headline_object ) return headlines_list
map articles results to a list of article objects
Args:
List of articles from the payload
map articles results to a list of article objects Args : List of articles from the payload
'''
  map articles results to a list of article objects

  Args:
      List of articles from the payload

  Returns:
        A list of articles objects
  '''
headlines_results