You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.7 KiB
49 lines
1.7 KiB
import datetime |
|
import json |
|
import time |
|
|
|
import requests |
|
from bs4 import BeautifulSoup |
|
# from random_user_agent.params import OperatingSystem, SoftwareName |
|
# from random_user_agent.user_agent import UserAgent |
|
from selenium import webdriver |
|
from selenium.webdriver.chrome.options import Options |
|
from selenium.webdriver.chrome.service import Service |
|
from selenium.webdriver.common.by import By |
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
|
|
|
def nonanon_options(): |
|
options = Options() |
|
options.add_argument("--start-maximized") |
|
options.add_argument("--ignore-certificate-errors") |
|
options.add_argument("--no-sandbox") |
|
options.add_argument("--disable-extensions") |
|
# options.add_argument('--profile-directory=Default') |
|
# options.add_argument("--user-data-dir=/tmp/chrome") |
|
|
|
# Disable webdriver flags or you will be easily detectable |
|
options.add_argument("--disable-blink-features") |
|
options.add_argument("--disable-blink-features=AutomationControlled") |
|
# extras |
|
options.add_argument( |
|
"Mozilla/5.0 (X11; CrOS x86_64 13597.105.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.208 Safari/537.36" |
|
) |
|
return options |
|
|
|
|
|
def nonanon_capabilities(session_id): |
|
capabilities = { |
|
"browserName": "chrome", |
|
"browserVersion": "latest", |
|
"pageLoadStrategy": "normal", |
|
"javascriptEnabled": True, |
|
"selenoid:options": { |
|
"enableVNC": True, |
|
"enableVideo": True, |
|
"enableLog": True, |
|
"videoName": f"{session_id}.mp4", |
|
"logName": f"{session_id}.log", |
|
"name": session_id, |
|
}, |
|
} |
|
return capabilities
|
|
|