Created
June 2, 2019 06:53
-
-
Save comdet/77f2fca79e095c1939a581fa5b32df77 to your computer and use it in GitHub Desktop.
This file contains 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
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import requests | |
import os | |
import time | |
import json | |
driver = webdriver.Firefox(executable_path="D:/AITOON/dataset/geckodriver.exe") | |
#login | |
driver.get("https://translate.webtoons.com/translate/tool?webtoonNo=182") | |
time.sleep(2) | |
driver.find_element_by_class_name("btn_facebook").click() | |
time.sleep(2) | |
driver.find_element_by_id("email").send_keys("xxxxxxxxx") | |
driver.find_element_by_id("pass").send_keys("xxxxxxxx") | |
driver.find_element_by_id("pass").send_keys(Keys.ENTER) | |
time.sleep(5) | |
#ep start from 1 to 129 | |
for ep in range(1,130): | |
print("get ep : " + str(ep)) | |
if not os.path.exists(""+str(ep)): | |
os.mkdir(""+str(ep)) | |
driver.get("https://translate.webtoons.com/translate/tool?webtoonNo=182&teamVersion=0&episodeNo="+str(ep)) | |
data = driver.execute_script("return translateData;") | |
#data[0] [u'backgroundOri', u'episodImg', u'height', u'width', u'background', u'sentences'] | |
for idx, val in enumerate(data): | |
if u'background' not in val: | |
continue | |
res = requests.get(val[u'background']) | |
if res.status_code == 200: | |
with open(str(ep)+"/"+str(idx)+".jpg", 'wb') as f: | |
f.write(res.content) | |
#backup next time | |
with open(str(ep)+'.json','w+') as j: | |
j.write(json.dumps(data)) | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment