import requests
from bs4 import BeautifulSoup


def general_scraper(url):
    """
    Scrapes the provided url link using python's requests module and returns a BS object containing returned information text
    Scraping wrapped around try-except blocks along with conditional check if status code is 200.

    Args:
        url ([str]): website to be scrapped.

    Returns:
        soup [Beautiful Soup object]: Returns scraped text in a Beautiful Soup object type.
    """

    try:
        response = requests.get(url)
        if response.status_code == 200:
            soup = BeautifulSoup(response.text, 'html5lib')
            return soup
        else:
            print(f"Did not get status code 200 for url: \n{url}\n.Instead got status code {response.status_code}")
            return None
    except Exception as err_msge:
        print(f"Error while scraping: {err_msge}")
        return None