Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- public class Testing {
- public static void main(String[] args) {
- String filePath = "H:/result.txt"; // This is the file which will have the end-result
- new File(filePath).delete(); // Delete it so we start a new fresh operation
- String allLines = "";
- for (int video = 1; video <= 200; video++) {
- System.out.println(video); // Just to keep an eye on the progress
- allLines += "\n" + "TAG SELECTOR=\"#videoApp tbody:nth-child(" + video + ") .video_title \" EXTRACT=TXT"; // Extract the title
- allLines += "\n" + "TAG SELECTOR=\"#videoApp tbody:nth-child(" + video + ") .video-description \" EXTRACT=TXT"; // Extract the Description
- allLines += "\n" + "SAVEAS TYPE=EXTRACT FOLDER=* FILE=H:\\CBT<SP>Nugget<SP>Descriptions.csv";
- allLines += "\n";
- allLines += "\n";
- saveToFile(filePath, true, allLines); // Save the buffer in the file
- allLines = ""; // Free the buffer to speed things up
- }
- }
- static void saveToFile(String filePath, boolean append, String linesToWrite) {
- try {
- FileWriter fw = new FileWriter(new File(filePath), append);
- fw.write(linesToWrite);
- fw.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement