Closed mohammad-fahs closed 2 weeks ago
Website Scraped:
I chose to scrape the laptops section from sbeitycomputers.com. The data I extracted includes the laptop title, price, image URL, and product link.
Java Code:
The Java code was implemented using the CommandLineRunner
interface. I used JSoup to parse the HTML and extract the relevant details for each laptop.
Code and Output:
Attachments: web_scraper.zip - Contains the Java code.
@mohammad-fahs
Task 2 :
Objective:
In this task, you will initialize a new Spring Boot project, add the JSoup dependency, and write a simple Java program to scrape data from a website of your choice. The goal is to get hands-on experience with setting up a Spring Boot project, using an external library (JSoup), and applying web scraping techniques.
Instructions:
com.yourname
web-scraper
Web Scraper
com.yourname.webscraper
Spring Web
dependency (to allow adding more features later).pom.xml
file in the root directory of your project.<dependencies>
tag:pom.xml
file and allow IntelliJ to update the Maven project to download the JSoup library.com.yourname.webscraper
package that implements theCommandLineRunner
interface.run
method, use JSoup to connect to the website you chose and scrape the data.Submit Your Work:
CommandLineRunner
.Resources that can help: