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 entry = 1; entry <= 1000; entry++) {
- System.out.println(entry); // Just to keep an eye on the progress
- 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)
- allLines += "\n" + "WAIT SECONDS=3"; // Wait some time so that the page gets loads new content using AJAX
- allLines += "\n" + "EVENT TYPE=CLICK SELECTOR=\"#vocab-rows>TR:nth-of-type(" + entry + ")\" BUTTON=0"; // Extract all the information needed from the side panel
- allLines += "\n" + "TAG POS=1 TYPE=A ATTR=CLASS:nav-skill EXTRACT=TXT"; // Extract the level title
- allLines += "\n" + "TAG SELECTOR=\"#word-sidebar>div.info-top>div.top-hint.left>div\" EXTRACT=TXT"; // Extract the German word
- allLines += "\n" + "TAG POS=1 TYPE=SPAN ATTR=ID:word-header EXTRACT=TXT"; // Extract the English translation
- allLines += "\n" + "SAVEAS TYPE=EXTRACT FOLDER=* FILE=H:\\Duolingo<SP>Words<SP>List.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