@@ -316,21 +316,31 @@ def main(argv):
316
316
if book_assets :
317
317
318
318
# get the list of books
319
- books_page = session .get ("https://www.packtpub.com/account/my-ebooks" , verify = True , headers = headers )
320
- books_tree = html .fromstring (books_page .content )
321
- book_nodes = books_tree .xpath ("//div[@id='product-account-list']/div[contains(@class,'product-line unseen')]" )
322
-
323
- print ('###########################################################################' )
324
- print ("FOUND {0} BOOKS: STARTING DOWNLOADS" .format (len (book_nodes )))
325
- print ('###########################################################################' )
326
-
327
- # loop through the books
328
- for book in book_nodes :
329
-
330
- # download the book
331
- books_directory = os .path .join (root_directory , "books" )
332
- download_book (book , books_directory , book_assets , session , headers )
333
-
319
+ page = 1
320
+ books_page = session .get ("https://www.packtpub.com/account/my-ebooks?page={0}" .format (page ), verify = True , headers = headers )
321
+ pages_tree = html .fromstring (books_page .content )
322
+ pages_nodes = pages_tree .xpath ("//*[contains(@class,'solr-page-page-selector-page')]" )
323
+ pages_max = (len (pages_nodes )) + 1
324
+ # added loop for the more PacktPub pages
325
+ for page in range ((pages_max )):
326
+ page += 1
327
+ url = 'https://www.packtpub.com/account/my-ebooks?page='
328
+ url = (url + str (page ))
329
+ books_page = session .get (url , verify = True , headers = headers )
330
+ books_tree = html .fromstring (books_page .content )
331
+ book_nodes = books_tree .xpath ("//div[@id='product-account-list']/div[contains(@class,'product-line unseen')]" )
332
+
333
+ print ('###########################################################################' )
334
+ print ("FOUND {0} BOOKS: STARTING DOWNLOADS" .format (len (book_nodes )))
335
+ print ('###########################################################################' )
336
+
337
+ # loop through thpages
338
+ for book in book_nodes :
339
+
340
+ # download the book
341
+ books_directory = os .path .join (root_directory , "books" )
342
+ download_book (book , books_directory , book_assets , session , headers )
343
+
334
344
if video_assets :
335
345
336
346
# get the list of videos
0 commit comments