Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python3
- import bs4, requests, time, os
- session = requests.session()
- payload = {'email': 'PUT_YOUR_EMAIL_HERE', 'password': 'PUT_YOUR_PASSWORD_HERE'}
- r = session.post(url='https://www.lovereading4kids.co.uk/login/?login=y', data=payload)
- def download(url, file_name):
- with open(file_name, "wb") as file:
- response = session.get(url)
- file.write(response.content)
- currentnum = 901
- endnum = 14477
- while currentnum <= endnum:
- res = session.get('http://lovereadingforkids.co.uk/book/'+str(currentnum))
- soup = bs4.BeautifulSoup(res.text, 'html.parser')
- coverinfo = soup.select_one('div[id="cover-column"] > img')
- try:
- print('Downloading '+str(currentnum)+': '+coverinfo['alt'].replace('/','-'))
- os.makedirs(str(currentnum)+': '+coverinfo['alt'].replace('/','-'))
- download('http://www.lovereading4kids.co.uk/_download/extract/'+str(currentnum), str(currentnum)+': '+coverinfo['alt'].replace('/','-')+'/'+coverinfo['alt'].replace('/','-')+'.pdf')
- download(coverinfo['src'], str(currentnum)+': '+coverinfo['alt'].replace('/','-')+'/'+'Cover.jpg')
- except TypeError:
- pass
- time.sleep(0.3)
- currentnum += 1
Add Comment
Please, Sign In to add comment