Skip to content

Commit

Permalink
Merge pull request #3571 from josepmonclus/reto18
Browse files Browse the repository at this point in the history
Reto #18 - Java
  • Loading branch information
Roswell468 authored May 25, 2023
2 parents 1af8ed6 + 62f0c57 commit 15c0596
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Retos/Reto #18 - WEB SCRAPING [Difícil]/java/josepmonclus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/*
* El día 128 del año celebramos en la comunidad el "Hola Mundo day"
* Vamos a hacer "web scraping" sobre su sitio web: https://holamundo.day
*
* Crea un programa que se conecte a la web del evento e imprima únicamente la agenda de eventos
* del día 8. Mostrando hora e información de cada uno.
* Ejemplo: "16:00 | Bienvenida"
*
* Se permite utilizar librerías que nos faciliten esta tarea.
*
*/

public class josepmonclus {
public static void main(String[] args) {
String url = "https://holamundo.day";

try {
// Realizar la solicitud HTTP y obtener el documento HTML
Document document = Jsoup.connect(url).get();

Elements paragraphElements = document.select("h1");
for(Element h1 : paragraphElements) {
if(h1.text().contains("Agenda 8 de mayo")) {
Elements agenda = h1.nextElementSiblings().select("blockquote");
for(Element event : agenda) {
System.out.println(event.text());
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 15c0596

Please sign in to comment.