'How to crawl the website with selenium in Heroku by Korean? (python)
I'm making a discord bot by Heroku and python that shows the information about league of legends champions. And I'm a Korean student. So I want to make this to show the information in Korean. I tried to change the chrome driver's language setting from English to Korean. if I run this code on my computer, it works. But if I run it on Heroku, it is still English.
This is the code that I set for the chrome driver.
import discord
import random
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import os
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") # setting for heroku
chrome_options.add_argument("--lang=ko-KR") # set to korean <-------
chrome_options.add_argument("--headless") # setting for heroku
chrome_options.add_argument("--disable-dev-shm-usage") # setting for heroku
chrome_options.add_argument("--no-sandbox") # setting for heroku
driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), chrome_options=chrome_options) # setting for heroku
Solution 1:[1]
You will need to add a korean proxy/vpn to chrome's webdriver. If you don't have a korean VPN, you could even make a reverse connection proxy, to your pc. In other terms, you could tunnel all the webdriver's internet traffic to your PC.
Look into socks5 reverse proxy with ssh. Then add your proxy to chrome's webdriver like that:
"""
Where PORTNUMBER is the port number of your proxy,
and IPADDRESS, the proxy's IP address:
"""
proxy = IPADDRESS+":"+str(PORTNUMBER)
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=socks5://' + proxy)
driver = webdriver.Chrome(options=options)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bastien Bastien |
