daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Nov 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def Crawl_Translation(request):
  2.     driver = webdriver.PhantomJS()
  3.  
  4.     driver.maximize_window()
  5.     driver.implicitly_wait(10)
  6.     action = action_chains.ActionChains(driver)
  7.  
  8.     URL = "https://translate.google.co.kr/#en/ko/"
  9.  
  10.     driver.get(URL)
  11.     driver.find_element_by_xpath('//*[@id="source"]').send_keys('I want to eat cheese hamburger')
  12.  
  13.     action.send_keys(keys.Keys.ENTER)
  14.     action.perform()
  15.     time.sleep(5)
  16.  
  17.     driver.save_screenshot('scrshot.png')
  18.  
  19.     driver.find_element_by_xpath('//*[@id="gt-res-listen"]').click()
  20.     time.sleep(5)
  21.  
  22.     soupstr = driver.find_element_by_xpath('//*[@id="result_box"]')
  23.  
  24.     return HttpResponse(soupstr.text)
RAW Paste Data
Top