|
|
|
@ -3,23 +3,25 @@
|
|
|
|
|
from selenium import webdriver
|
|
|
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
|
from lxml import etree
|
|
|
|
|
import random
|
|
|
|
|
import settings
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36'
|
|
|
|
|
'User-Agent': random.choice(settings.USER_AGENT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def getsource(url):
|
|
|
|
|
init = Options()
|
|
|
|
|
initChrome = Options()
|
|
|
|
|
|
|
|
|
|
init.add_argument('--no-sandbox')
|
|
|
|
|
init.add_argument('--headless')
|
|
|
|
|
init.add_argument('--disable-gpu')
|
|
|
|
|
init.add_argument("disable-cache")
|
|
|
|
|
init.add_argument('disable-infobars')
|
|
|
|
|
init.add_argument('log-level=3') # INFO = 0 WARNING = 1 LOG_ERROR = 2 LOG_FATAL = 3 default is 0
|
|
|
|
|
init.add_experimental_option("excludeSwitches",['enable-automation','enable-logging'])
|
|
|
|
|
initChrome.add_argument('--no-sandbox')
|
|
|
|
|
initChrome.add_argument('--headless')
|
|
|
|
|
initChrome.add_argument('--disable-gpu')
|
|
|
|
|
initChrome.add_argument("disable-cache")
|
|
|
|
|
initChrome.add_argument('disable-infobars')
|
|
|
|
|
initChrome.add_argument('log-level=3') # INFO = 0 WARNING = 1 LOG_ERROR = 2 LOG_FATAL = 3 default is 0
|
|
|
|
|
initChrome.add_experimental_option("excludeSwitches",['enable-automation','enable-logging'])
|
|
|
|
|
|
|
|
|
|
driver = webdriver.Chrome(chrome_options = init)
|
|
|
|
|
driver = webdriver.Chrome(chrome_options = initChrome, executable_path = './chromedriver.exe')
|
|
|
|
|
driver.implicitly_wait(10)
|
|
|
|
|
driver.get(url)
|
|
|
|
|
|
|
|
|
|