Compare commits

...

2 Commits

Author SHA1 Message Date
68ec9d52ed Did a lot of groundwork 2024-11-21 15:16:23 -06:00
307745babe Basic dev notes 2024-11-21 05:56:21 -06:00
13 changed files with 61 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
target/ target/
.vscode/ .vscode/
tomcat-binaries/

View File

@ -1,3 +1,26 @@
# amazon-scrapi # amazon-scrapi
An API interface with Amazon, that uses webscraping An API interface with Amazon, that uses webscraping
# Development Environment Setup
## VSCode / VSCodium
Install the following softwares
- Required for development
- Maven
- Java JDK
- Git
- Highly recommended for debugging or deployment
- [Apache Tomcat](https://tomcat.apache.org)
- Docker
VSCode Extensions
- Extension Pack for Java
### Tomcat
Download binaries for Tomcat.
You can get a VSCode extension to deploying project to Tomcat for debugging.
Following these guides.
- Extension Setup [(Video](https://www.youtube.com/watch?v=R9mugpHWr14) - [Article)](https://www.brandondonnelson.com/2020/06/debugging-java-web-app-in-visual-studio.html).
- Helped understand config [(video)](https://www.youtube.com/watch?v=RiPot1ne8rI)

View File

@ -28,6 +28,11 @@
<version>3.8.1</version> <version>3.8.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.48.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -8,11 +8,28 @@ import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
public class App extends HttpServlet { public class App extends HttpServlet {
@Override @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String url = "https://amazon.com";
PrintWriter out = resp.getWriter(); PrintWriter out = resp.getWriter();
out.println("Hello!");
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
Page page = browser.newPage();
page.navigate(url);
page.
System.out.println(page.title());
out.println("Here is the page.title: " + page.title());
}
out.close(); out.close();
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

12
src/main/webapp/index.jsp Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Amazon Scrapi</title>
</head>
<body>
<h2>Amazon Scrapi</h2>
<hr />
<p>An API interface with amazon.com using webscraping</p>
</body>
</html>