Skip to content

A Java backend application built with Spring Boot that performs web scraping using Jsoup to collect news from the Sucesso no Campo website. The data is stored in a MySQL database and exposed through a RESTful API for easy integration and consumption.

Notifications You must be signed in to change notification settings

LuizStSantos/NewsAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📰 NewsAPI

NewsAPI is a RESTful API built with Java and Spring Boot that performs web scraping on the website Sucesso no Campo to collect and store news articles in a MySQL database. It also provides a simple front-end to view and search for articles.


📌 Features

  • ✅ Web scraping using Jsoup
  • ✅ RESTful API with Spring Boot
  • ✅ Search news by title (case-insensitive)
  • ✅ Save news with title, content, image, publication date, and source
  • ✅ Prevent duplicate news entries
  • ✅ Simple HTML front-end to search and view news

🚀 Tech Stack

Technology Description
Java 17 Programming language
Spring Boot Backend framework
Spring Data JPA ORM and database abstraction
MySQL Relational database
Jsoup Web scraping library
HTML + JS Simple frontend interface

🗂️ Project Structure

NewsAPI/
├── src/
│   └── main/
│       ├── java/
│       │   └── com.github.luizstsantos.NewsAPI/
│       │       ├── controller/
│       │       │   ├── ControlNews.java
│       │       │   └── ControlScraper.java
│       │       ├── model/
│       │       │   └── News.java
│       │       ├── repository/
│       │       │   └── NewsRepository.java
│       │       ├── scraper/
│       │       │   └── Scraper.java
│       │       ├── service/
│       │       │   └── NewsService.java
│       │       ├── NewsApiApplication.java
│       │       └── ScraperRunner.java
│       ├── resources/
│       │   ├── static/
│       │   │   ├── index.html
│       │   │   └── news.html
│       │   ├── templates/
│       │   └── application.properties
└── test/

⚙️ Setup Instructions

✅ Prerequisites

  • Java 17+
  • Maven
  • MySQL Server

🔧 Database Setup

Create the database:

CREATE DATABASE NewsAPI CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Update your application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/NewsAPI?useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

▶️ Run the application

./mvnw spring-boot:run

Or build and run the jar:

mvn clean install
java -jar target/NewsAPI-0.0.1-SNAPSHOT.jar

🌐 API Endpoints

Method Endpoint Description
GET /news Returns all news articles
GET /news/search Search news by title (query param title)

Example:

curl http://localhost:8080/news/search?title=agriculture

🖥️ Front-end (Basic)

Open index.html in your browser, or place it inside src/main/resources/static/ to serve it with Spring Boot.

http://localhost:8080/index.html

🧑‍💻 Author

Made with 💻 by LuizStSantos
If you like it, give it a ⭐ on GitHub!


📝 License

This project is licensed under the MIT License.

About

A Java backend application built with Spring Boot that performs web scraping using Jsoup to collect news from the Sucesso no Campo website. The data is stored in a MySQL database and exposed through a RESTful API for easy integration and consumption.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published