Advertisement
TheDemystifier

Duolingo Words List

Jun 4th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileWriter;
  3. import java.io.IOException;
  4.  
  5. public class Testing {
  6.     public static void main(String[] args) {
  7.         String filePath = "H:/result.txt"; // This is the file which will have the end-result
  8.         new File(filePath).delete(); // Delete it so we start a new fresh operation
  9.         String allLines = "";
  10.         for (int entry = 1; entry <= 1000; entry++) {
  11.             System.out.println(entry); // Just to keep an eye on the progress
  12.             allLines += "\n" + "EVENT TYPE=CLICK SELECTOR=\"#vocab-rows>TR:nth-of-type(" + entry + ")\" BUTTON=99"; // This should work the same as a hover since thats not yet available in iMacro (Except the stupid XY coordinates thingy)
  13.             allLines += "\n" + "WAIT SECONDS=3"; // Wait some time so that the page gets loads new content using AJAX
  14.             allLines += "\n" + "EVENT TYPE=CLICK SELECTOR=\"#vocab-rows>TR:nth-of-type(" + entry + ")\" BUTTON=0"; // Extract all the information needed from the side panel
  15.             allLines += "\n" + "TAG POS=1 TYPE=A ATTR=CLASS:nav-skill EXTRACT=TXT"; // Extract the level title
  16.             allLines += "\n" + "TAG SELECTOR=\"#word-sidebar>div.info-top>div.top-hint.left>div\" EXTRACT=TXT"; // Extract the German word
  17.             allLines += "\n" + "TAG POS=1 TYPE=SPAN ATTR=ID:word-header EXTRACT=TXT"; // Extract the English translation
  18.             allLines += "\n" + "SAVEAS TYPE=EXTRACT FOLDER=* FILE=H:\\Duolingo<SP>Words<SP>List.csv";
  19.             allLines += "\n";
  20.             allLines += "\n";
  21.             saveToFile(filePath, true, allLines); // Save the buffer in the file
  22.             allLines = ""; // Free the buffer to speed things up
  23.         }
  24.     }
  25.  
  26.     static void saveToFile(String filePath, boolean append, String linesToWrite) {
  27.         try {
  28.             FileWriter fw = new FileWriter(new File(filePath), append);
  29.             fw.write(linesToWrite);
  30.             fw.close();
  31.         } catch (IOException e) {
  32.             e.printStackTrace();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement