Created
February 13, 2021 10:49
-
-
Save sh-cho/e0e6590233724f74a5a719d69efb00e0 to your computer and use it in GitHub Desktop.
daum webtoon scraper using selenium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import urllib.request | |
from selenium.webdriver.chrome.options import Options | |
from selenium import webdriver | |
VIEWER_PATH = "http://webtoon.daum.net/webtoon/viewer/" | |
def selenium_download_episode(driver: webdriver.Chrome, episode_id: int): | |
driver.get(VIEWER_PATH + str(episode_id)) | |
time.sleep(3) | |
images = driver.find_elements_by_css_selector("#imgView > img.img_webtoon") | |
for index, image in enumerate(images): | |
img_src = image.get_attribute("src") | |
urllib.request.urlretrieve(img_src, f"{index:04d}.jpg") | |
if __name__ == "__main__": | |
opts = Options() | |
opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") | |
driver = webdriver.Chrome() | |
selenium_download_episode(driver, 84333) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment