Advertisement
IanosStefanCristian

Webscraping

Jul 13th, 2020
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. package com.imdb;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.jsoup.Jsoup;
  6. import org.jsoup.nodes.Document;
  7. import org.jsoup.nodes.Element;
  8. import org.jsoup.select.Elements;
  9.  
  10. public class FetchIMDBMovieList {
  11.  
  12. public static void main(String[] args) {
  13.  
  14. try {
  15.  
  16. Document doc=Jsoup.connect("https://www.imdb.com/search/title/?title_type=feature&num_votes=25000,&genres=action&sort=alpha,asc").userAgent("Brave/1.10").get();
  17. Elements temp = doc.select("h3.lister-item-header");
  18.  
  19. int i=0;
  20. for(Element movieList:temp)
  21. {
  22. i++;
  23. System.out.println(i+ " "+ movieList.getElementsByTag("a").first().text());
  24. }
  25.  
  26. }
  27.  
  28.  
  29. catch(IOException e) {
  30. e.printStackTrace();
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement