Updates to PACKT claimer/downloader.

This commit is contained in:
Markus Birth 2018-09-27 01:49:03 +02:00
parent c545de0b35
commit 3bfc387394
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
2 changed files with 6 additions and 4 deletions

View File

@ -36,9 +36,11 @@ g.doc.text_assert('"sid":')
g.doc.text_assert('Claim Your Free eBook')
claim_book = g.doc.select('//div[@class="dotd-title"]/h2').text()
print("Book: {}".format(claim_book))
claim_url = g.doc.select('//a[@class="twelve-days-claim"]/@href').text()
claim_url = g.doc.select('//form[@id="free-learning-form"]/@action').text()
print("Claim URL: {}".format(claim_url))
g.go(claim_url)
g.doc.choose_form(id='free-learning-form')
g.doc.submit()
#g.go(claim_url)
g.doc.save('/tmp/free-learning-after-claim.html')
g.doc.text_assert('<h1>My eBooks </h1>')
print("Claim successful.")

View File

@ -147,7 +147,7 @@ else:
print("Found {:d} ebooks.".format(len(all_books)))
if opts["idx_end"] or opts["count"]:
if opts["idx_start"] > 1 or opts["idx_end"] or opts["count"]:
# Some range given: Download books
idx_start = opts["idx_start"]
if idx_start < 1:
@ -158,7 +158,7 @@ if opts["idx_end"] or opts["count"]:
elif opts["count"]:
idx_end = idx_start + opts["count"] - 1
else:
idx_end = idx_start
idx_end = len(all_books)
if idx_end < idx_start:
idx_end = idx_start