import requests from bs4 import BeautifulSoup def extract_news(url): response = requests.get(url) if response.status_code != 200: return None soup = BeautifulSoup(response.text, 'html.parser') # Extraindo o título title_tag = soup.find('h1', class_='elementor-heading-title') title = title_tag.text.strip() if title_tag else 'Título não encontrado' # Extraindo a data date_tag = soup.find('ul', class_='elementor-post-info') date = date_tag.find('time').text.strip() if date_tag and date_tag.find('time') else 'Data não encontrada' # Extraindo a imagem destacada image_tag = soup.find('img', class_='attachment-full') image_url = image_tag['src'] if image_tag else 'Imagem não encontrada' # Extraindo o conteúdo content_tag = soup.find('div', class_='elementor-widget-container') content = content_tag.get_text(separator='\n').strip() if content_tag else 'Conteúdo não encontrado' return { 'title': title, 'date': date, 'image_url': image_url, 'content': content }{"id":195,"count":1,"description":"","link":"https:\/\/www.noticiasms.com\/categoria\/historia\/","name":"Hist\u00f3ria","slug":"historia","taxonomy":"category","parent":0,"meta":[],"yoast_head":"\nArquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.noticiasms.com\/categoria\/historia\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.noticiasms.com\/categoria\/historia\/\" \/>\n<meta property=\"og:site_name\" content=\"Not\u00edcias MS - Mais do que voc\u00ea imagina!\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t \"@context\": \"https:\/\/schema.org\",\n\t \"@graph\": [\n\t {\n\t \"@type\": \"CollectionPage\",\n\t \"@id\": \"https:\/\/www.noticiasms.com\/categoria\/historia\/\",\n\t \"url\": \"https:\/\/www.noticiasms.com\/categoria\/historia\/\",\n\t \"name\": \"Arquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!\",\n\t \"isPartOf\": {\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#website\"\n\t },\n\t \"breadcrumb\": {\n\t \"@id\": \"https:\/\/www.noticiasms.com\/categoria\/historia\/#breadcrumb\"\n\t },\n\t \"inLanguage\": \"pt-BR\"\n\t },\n\t {\n\t \"@type\": \"BreadcrumbList\",\n\t \"@id\": \"https:\/\/www.noticiasms.com\/categoria\/historia\/#breadcrumb\",\n\t \"itemListElement\": [\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 1,\n\t \"name\": \"In\u00edcio\",\n\t \"item\": \"https:\/\/www.noticiasms.com\/\"\n\t },\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 2,\n\t \"name\": \"Hist\u00f3ria\"\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"WebSite\",\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#website\",\n\t \"url\": \"https:\/\/www.noticiasms.com\/\",\n\t \"name\": \"Not\u00edcias MS - Mais do que voc\u00ea imagina!\",\n\t \"description\": \"Not\u00edcias, informa\u00e7\u00f5es e entretenimento.\",\n\t \"publisher\": {\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#organization\"\n\t },\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"SearchAction\",\n\t \"target\": {\n\t \"@type\": \"EntryPoint\",\n\t \"urlTemplate\": \"https:\/\/www.noticiasms.com\/?s={search_term_string}\"\n\t },\n\t \"query-input\": {\n\t \"@type\": \"PropertyValueSpecification\",\n\t \"valueRequired\": true,\n\t \"valueName\": \"search_term_string\"\n\t }\n\t }\n\t ],\n\t \"inLanguage\": \"pt-BR\"\n\t },\n\t {\n\t \"@type\": \"Organization\",\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#organization\",\n\t \"name\": \"Not\u00edcias MS - Mais do que voc\u00ea imagina!\",\n\t \"url\": \"https:\/\/www.noticiasms.com\/\",\n\t \"logo\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"pt-BR\",\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#\/schema\/logo\/image\/\",\n\t \"url\": \"https:\/\/www.noticiasms.com\/wp-content\/uploads\/2019\/02\/LogoTop-site.png\",\n\t \"contentUrl\": \"https:\/\/www.noticiasms.com\/wp-content\/uploads\/2019\/02\/LogoTop-site.png\",\n\t \"width\": 175,\n\t \"height\": 120,\n\t \"caption\": \"Not\u00edcias MS - Mais do que voc\u00ea imagina!\"\n\t },\n\t \"image\": {\n\t \"@id\": \"https:\/\/www.noticiasms.com\/#\/schema\/logo\/image\/\"\n\t },\n\t \"sameAs\": [\n\t \"https:\/\/www.facebook.com\/notims\",\n\t \"https:\/\/www.instagram.com\/noticiasms\"\n\t ]\n\t }\n\t ]\n\t}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.noticiasms.com\/categoria\/historia\/","og_locale":"pt_BR","og_type":"article","og_title":"Arquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!","og_url":"https:\/\/www.noticiasms.com\/categoria\/historia\/","og_site_name":"Not\u00edcias MS - Mais do que voc\u00ea imagina!","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"CollectionPage","@id":"https:\/\/www.noticiasms.com\/categoria\/historia\/","url":"https:\/\/www.noticiasms.com\/categoria\/historia\/","name":"Arquivo de Hist\u00f3ria - Not\u00edcias MS - Mais do que voc\u00ea imagina!","isPartOf":{"@id":"https:\/\/www.noticiasms.com\/#website"},"breadcrumb":{"@id":"https:\/\/www.noticiasms.com\/categoria\/historia\/#breadcrumb"},"inLanguage":"pt-BR"},{"@type":"BreadcrumbList","@id":"https:\/\/www.noticiasms.com\/categoria\/historia\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/www.noticiasms.com\/"},{"@type":"ListItem","position":2,"name":"Hist\u00f3ria"}]},{"@type":"WebSite","@id":"https:\/\/www.noticiasms.com\/#website","url":"https:\/\/www.noticiasms.com\/","name":"Not\u00edcias MS - Mais do que voc\u00ea imagina!","description":"Not\u00edcias, informa\u00e7\u00f5es e entretenimento.","publisher":{"@id":"https:\/\/www.noticiasms.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.noticiasms.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.noticiasms.com\/#organization","name":"Not\u00edcias MS - Mais do que voc\u00ea imagina!","url":"https:\/\/www.noticiasms.com\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.noticiasms.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.noticiasms.com\/wp-content\/uploads\/2019\/02\/LogoTop-site.png","contentUrl":"https:\/\/www.noticiasms.com\/wp-content\/uploads\/2019\/02\/LogoTop-site.png","width":175,"height":120,"caption":"Not\u00edcias MS - Mais do que voc\u00ea imagina!"},"image":{"@id":"https:\/\/www.noticiasms.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/notims","https:\/\/www.instagram.com\/noticiasms"]}]}},"_links":{"self":[{"href":"https:\/\/www.noticiasms.com\/wp-json\/wp\/v2\/categories\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.noticiasms.com\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"https:\/\/www.noticiasms.com\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"https:\/\/www.noticiasms.com\/wp-json\/wp\/v2\/posts?categories=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}