Guest User

FFScraper.pde

a guest
Sep 30th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. //For use in Processing 3: https://processing.org
  2.  
  3. //int ficID=5193644;//Time Braid
  4. //int chapterCount=31;
  5.  
  6. int ficID=12097887;
  7. int chapterCount=19;
  8. String chapters[]=new String[chapterCount];
  9. String thisChapter[]=new String[1];
  10. int chapter,secondsToWait=5;
  11.  
  12. void setup(){
  13.   noLoop();
  14. }
  15.  
  16. void draw(){
  17.   for(chapter=1;chapter<=chapterCount;chapter++){
  18.     chapters[chapter-1]=join(loadStrings("https://www.fanfiction.net/s/"+ficID+"/"+chapter+"/")," ");//FanFiction.net
  19.     //chapters[chapter-1]=join(loadStrings("https://www.fictionpress.com/s/"+ficID+"/"+chapter+"/")," ");//FictionPress.com
  20.     chapters[chapter-1]=chapters[chapter-1].substring(chapters[chapter-1].indexOf("'storytext'>")+12);//Remove extraneous stuff before chapter text
  21.     chapters[chapter-1]="<h2>"+chapter+"</h2>"+chapters[chapter-1].substring(0,chapters[chapter-1].indexOf("</div>"));//Remove extraneous stuff after chapter text, and add preliminary chapter headings
  22.     thisChapter[0]=chapters[chapter-1];
  23.     saveStrings("output/"+chapter+".html",thisChapter);
  24.     println("Chapter "+chapter+" of "+chapterCount+" obtained...");
  25.     if(chapter<chapterCount){
  26.       delay(secondsToWait*1000);//Avoid overloading servers and getting banned
  27.     }
  28.   }
  29.   if(chapterCount>1){
  30.     saveStrings("output/0.html",chapters);
  31.   }
  32.   println("Done!");
  33.   exit();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment