Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.videoScrap;
- import java.io.BufferedInputStream;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.net.URL;
- import java.util.Arrays;
- import java.util.List;
- import java.util.stream.Collectors;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- public class App {
- public static void main(String[] args) {
- for (int i = Integer.parseInt(args[0]); i >= 1; i--) {
- System.out.println(String.format("Page: %s", i));
- String url = String.format("https://sexycandidgirls.com/page/%s", i);
- try {
- Document document = Jsoup.connect(url).get();
- for (Element aTag : document.select(".g1-frame")) {
- Document doc = Jsoup.connect(aTag.attr("href")).get();
- for (Element iFrame : doc.select("iframe")) {
- if (iFrame.hasAttr("data-lazy-src")) {
- String lastUrl = iFrame.absUrl("data-lazy-src");
- Document videoDoc = Jsoup.connect(lastUrl).get();
- List<String> data = Arrays
- .asList(videoDoc.select("script").get(11).toString().split("\\|"));
- String id = data.stream().filter(word -> word.length() == 60)
- .collect(Collectors.joining(""));
- String fs = data.stream().filter(word -> word.startsWith("fs"))
- .collect(Collectors.joining(""));
- if (!checkIfAlreadyExists(id)) {
- System.out.println("Does not exists");
- String videoUrl = String.format("https://%s.gounlimited.to/%s/v.mp4", fs, id);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(
- new URL(videoUrl).openStream());
- FileOutputStream fileOutputStream = new FileOutputStream(String
- .format("C:/Users/Haphk/Desktop/Coding/Java/video-scrap/videos/%s.mp4", id));
- int count = 0;
- byte[] b = new byte[1024];
- while ((count = bufferedInputStream.read(b)) != -1) {
- fileOutputStream.write(b, 0, count);
- }
- fileOutputStream.flush();
- fileOutputStream.close();
- } else {
- System.out.println("Already exists");
- }
- }
- }
- }
- } catch (
- IOException e) {
- e.printStackTrace();
- }
- }
- }
- public static Boolean checkIfAlreadyExists(String input) {
- File folder = new File("C:/Users/Haphk/Desktop/Coding/Java/video-scrap/videos/");
- File[] listOfFiles = folder.listFiles();
- List<String> currentFileNames = Arrays.asList(listOfFiles).stream()
- .map(file -> file.getName().substring(0, file.getName().length() - 13)).collect(Collectors.toList());
- return currentFileNames.stream().anyMatch(id -> id.trim().equals(input.substring(0, input.length() - 9)));
- }
- }
RAW Paste Data