@@ -70,7 +70,7 @@ public Document getFirstPage() throws IOException {
7070
7171 if (!tagPage ) {
7272 rootUrlStr = url .toExternalForm ().replaceAll ("(|/|/[0-9]+/?)$" , "/" );
73- } else { // 6-10-21
73+ } else {
7474 rootUrlStr = url .toExternalForm ().replaceAll ("(page/[0-9]+/)$" , "page/1/" );
7575 }
7676
@@ -94,9 +94,7 @@ public Document getNextPage(Document doc) throws IOException {
9494 urlStr = url .toExternalForm ().replaceAll ("(/([0-9]*)/?)$" , ("/" + (pageNum + 1 ) + "/" ));
9595 System .out .printf ("Old Str: %s New Str: %s\n " , url .toString (), urlStr );
9696 } else {
97- // System.out.printf("Error: Page number provided goes past last valid page
98- // number\n");
99- throw (new IOException ("Error: Page number provided goes past last valid page number\n " ));
97+ throw new IOException ("Error: Page number provided goes past last valid page number\n " );
10098 }
10199 } else { // 6-10-21
102100 // if (pageNum == 1 && lastPageNum >= 1) {
@@ -107,18 +105,14 @@ public Document getNextPage(Document doc) throws IOException {
107105 urlStr = url .toExternalForm ().replaceAll ("(page/([0-9]*)/?)$" , ("page/" + (pageNum + 1 ) + "/" ));
108106 System .out .printf ("Old Str: %s New Str: %s\n " , url .toString (), urlStr );
109107 } else {
110- // System.out.printf("Error: Page number provided goes past last valid page
111- // number\n");
112108 System .out .print ("Error: There is no next page!\n " );
113109 return null ;
114- // throw (new IOException("Error: Page number provided goes past last valid page
115- // number\n"));
116110 }
117111 }
118112
119113 url = URI .create (urlStr ).toURL ();
120114 currDoc = Http .url (url ).get ();
121- currPageNum ++;// hi
115+ currPageNum ++;
122116 return currDoc ;
123117 }
124118
@@ -143,22 +137,9 @@ private int getMaxPageNumber(Document doc) {
143137 return lastPageNum ;
144138 }
145139
146- private int getCurrentPageNum (Document doc ) {
147- int currPage ; // 6-10-21
148-
149- if (!tagPage ) {
150- currPage = Integer .parseInt (doc .select ("div.page-link > span" ).first ().text ());
151- } else {
152- currPage = Integer .parseInt (doc .select ("div.pagination > span" ).first ().text ());
153- }
154-
155- System .out .println ("The current page was found to be: " + currPage );
156-
157- return currPage ;
158- }
159-
160140 @ Override
161- public List <String > getURLsFromPage (Document doc ) { // gets the urls of the images
141+ public List <String > getURLsFromPage (Document doc ) {
142+ // gets the urls of the images
162143 List <String > result = new ArrayList <>();
163144
164145 if (!tagPage ) {
0 commit comments