import requests
import requests_cache
import logging
requests_cache.install_cache('stack_cache')
url = 'https://api.stackexchange.com/2.2/similar?'


def get_stack_source(title):
    try:
        params = {'order': 'desc', 'sort': 'relevance', 'title': title,
            'site': 'stackoverflow'}
        response = requests.get(url, params).json()
        logging.info('stackoverflow API call started')
        resp_dict = {}
        i = 0
        while i < 5:
            item = response['items'][i]
            resp_dict.update({('item' + str(i)): {'title': item['title'],
                'link': item['link']}})
            i += 1
        return resp_dict
    except Exception as e:
        print('Error ', e)
        logging.info('stackoverflow exception caught')

606ab08237ba8e5c3783c3f35106f787d326cd90
<mask token>


def get_stack_source(title):
    try:
        params = {'order': 'desc', 'sort': 'relevance', 'title': title,
            'site': 'stackoverflow'}
        response = requests.get(url, params).json()
        logging.info('stackoverflow API call started')
        resp_dict = {}
        i = 0
        while i < 5:
            item = response['items'][i]
            resp_dict.update({('item' + str(i)): {'title': item['title'],
                'link': item['link']}})
            i += 1
        return resp_dict
    except Exception as e:
        print('Error ', e)
        logging.info('stackoverflow exception caught')

<mask token>
requests_cache.install_cache('stack_cache')
<mask token>


def get_stack_source(title):
    try:
        params = {'order': 'desc', 'sort': 'relevance', 'title': title,
            'site': 'stackoverflow'}
        response = requests.get(url, params).json()
        logging.info('stackoverflow API call started')
        resp_dict = {}
        i = 0
        while i < 5:
            item = response['items'][i]
            resp_dict.update({('item' + str(i)): {'title': item['title'],
                'link': item['link']}})
            i += 1
        return resp_dict
    except Exception as e:
        print('Error ', e)
        logging.info('stackoverflow exception caught')

<mask token>
requests_cache.install_cache('stack_cache')
url = 'https://api.stackexchange.com/2.2/similar?'


def get_stack_source(title):
    try:
        params = {'order': 'desc', 'sort': 'relevance', 'title': title,
            'site': 'stackoverflow'}
        response = requests.get(url, params).json()
        logging.info('stackoverflow API call started')
        resp_dict = {}
        i = 0
        while i < 5:
            item = response['items'][i]
            resp_dict.update({('item' + str(i)): {'title': item['title'],
                'link': item['link']}})
            i += 1
        return resp_dict
    except Exception as e:
        print('Error ', e)
        logging.info('stackoverflow exception caught')

import requests
import requests_cache
import logging
requests_cache.install_cache('stack_cache')
url = 'https://api.stackexchange.com/2.2/similar?'


def get_stack_source(title):
    try:
        params = {'order': 'desc', 'sort': 'relevance', 'title': title,
            'site': 'stackoverflow'}
        response = requests.get(url, params).json()
        logging.info('stackoverflow API call started')
        resp_dict = {}
        i = 0
        while i < 5:
            item = response['items'][i]
            resp_dict.update({('item' + str(i)): {'title': item['title'],
                'link': item['link']}})
            i += 1
        return resp_dict
    except Exception as e:
        print('Error ', e)
        logging.info('stackoverflow exception caught')
