import requests
from bs4 import BeautifulSoup

def getNews(url):
    response = requests.get(url)

    if response.status_code == 200:
        soup = BeautifulSoup(response.text, 'html.parser')

        articles = soup.find_all('article', class_='news__item')

        for index, article in enumerate(articles, start=1):
            title = article.find('h2').text.strip()
            content = article.find('p').text.strip()
            category = article.find('span').text.strip()

            print(f"{index}. Title: {title}")
            print(f"   Content: {content}")
            print(f"   Category: {category}")
            print('****************************')
    else:
        print(f"Error. Status code: {response.status_code}")

if __name__ == "__main__":
    pUrl = 'https://srpskainfo.com/sve-vijesti/'

    getNews(pUrl)
