Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! python3
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- import requests, os, bs4, time, sys, pyautogui
- def newManga(nName):
- # Open Chrome and navigate to latest manga chapter for nName
- browser = webdriver.Chrome()
- browser.get(('http://mangakakalot.com/'))
- search = browser.find_element_by_id('search_story')
- search.send_keys(nName)
- pyautogui.typewrite(['enter'])
- latestChap = browser.find_element_by_class_name('item-chapter')
- latestChap.click()
- # Download the Page
- url = browser.current_url
- print('Downloading page %s...' % url)
- res = requests.get(url)
- res.raise_for_status()
- soup = bs4.BeautifulSoup(res.text, 'lxml')
- # Find the url of the manga image.
- mangaElem = soup.select('#vungdoc img')
- if mangaElem == []:
- print('Could not find manga image.')
- else:
- i = 0
- for i in mangaElem:
- mangaUrl = mangaElem[int(i)].get('src')
- # Download the image.
- print('Download image %s...' % (mangaUrl))
- res = requests.get(mangaUrl)
- requestses.raise_for_status()
- # Save the image to ./manga
- imageFile = open(os.path.join('manga', os.path.basename(mangaUrl)), 'wb')
- for chunk in res.iter_content(1000000):
- imageFile.write(chunk)
- imageFile.close()
- i += 1
- # Ask for new manga
- print('Do you have a new manga to add? Y or N')
- confirm = input()
- # If Y or y, input manga name as nName, cale newManga(nName)
- if confirm == 'Y' or 'y':
- print('Enter manga name to search: ')
- nName = input()
- newManga(nName)
- else:
- print('No new manga, closing...')
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement