Я пытаюсь настроить свой небольшой сканер как проект Docker. Я использую Selenium Wire, поэтому могу запускать более одного запроса одновременно. Однако теперь я хочу настроить прокси-сервер и столкнулся с несколькими проблемами.
Вот мой код:
Requirement.txt< /p>
selenium==4.0.0
selenium-wire==5.1.0
blinker==1.7.0
setuptools==74.0.0
requests
fake_useragent==1.5.1
Мой файл Docker-Compose:
Docker-Compose
version: '3'
services:
chrome:
image: selenium/node-chrome:4.10.0
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=10
networks:
- selenium-network
selenium-hub:
image: selenium/hub:4.10.0
container_name: selenium-hub
ports:
- "4444:4444"
networks:
- selenium-network
python-app:
build:
context: .
dockerfile: Dockerfile.future
depends_on:
- selenium-hub
networks:
- selenium-network
networks:
selenium-network:
driver: bridge
Dockerfile.future
FROM python
WORKDIR /
COPY requirements.txt .
COPY test_with_futures.py .
RUN pip install -r requirements.txt
CMD ["python", "test_with_futures.py"]
и мой код Python "Test_with_futures.py"
print("Docker gestartet")
import time
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
import concurrent
from fake_useragent import UserAgent
from random import random
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def call_function():
try:
# PROXY SETTINGS
PROXY = f"http://USER:PW@de.smartproxy.com:20000"
desired_capabilities = DesiredCapabilities.CHROME.copy() # Necessary cause it wants t use Firefox.
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument(f'--proxy-server={PROXY}') # If i dont use this, there Proxy will not be used, everthing will happen with my own IP.
# Setzen des Proxys in den Selenium Wire Optionen
seleniumwire_options = {
'auto_config': False,
'proxy': {
'http': PROXY,
'https': PROXY
}
}
driver = webdriver.Remote(
command_executor="http://selenium-hub:4444/wd/hub",
options=chrome_options,
seleniumwire_options=seleniumwire_options,
desired_capabilities=desired_capabilities
)
print("----------------- AKTUELLER PROXY -------------------------------------------")
print(driver.proxy)
print("------------------------------------------------------------")
driver.get("https://ip.smartproxy.com/json")
wait = WebDriverWait(driver, 50) # Warte bis zu 50 Sekunden
pre_element = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/pre")))
res = pre_element.text
print("----------------- DRIVER -----------------------------------")
print(res)
print("------------------------------------------------------------")
return "", "" # Not used at the moment
except Exception as e:
print(e)
finally:
driver.quit()
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
futures = []
for i in range(0, 5):
print(f"Webseitenindex {i}")
future = executor.submit(call_function)
futures.append(future)time.sleep(1)
for future in futures:
ipv4_value, ipv6_value = future.result() # Entpacken des Tupleprint(f"IPv4: {ipv4_value}, IPv6: {ipv6_value}")
Can someone help me please?
Вот сообщение об ошибке, которое я получаю:
2024-10-07 11:41:07 Message:
2024-10-07 11:41:07 Stacktrace:
2024-10-07 11:41:07 #0 0x55c1df1544e3
2024-10-07 11:41:07 #1 0x55c1dee83c76
2024-10-07 11:41:07 #2 0x55c1deebfc96
2024-10-07 11:41:07 #3 0x55c1deebfdc1
2024-10-07 11:41:07 #4 0x55c1deef97f4
2024-10-07 11:41:07 #5 0x55c1deedf03d
2024-10-07 11:41:07 #6 0x55c1deef730e
2024-10-07 11:41:07 #7 0x55c1deedede3
2024-10-07 11:41:07 #8 0x55c1deeb42dd
2024-10-07 11:41:07 #9 0x55c1deeb534e
2024-10-07 11:41:07 #10 0x55c1df1143e4
2024-10-07 11:41:07 #11 0x55c1df1183d7
2024-10-07 11:41:07 #12 0x55c1df122b20
2024-10-07 11:41:07 #13 0x55c1df119023
2024-10-07 11:41:07 #14 0x55c1df0e71aa
2024-10-07 11:41:07 #15 0x55c1df13d6b8
2024-10-07 11:41:07 #16 0x55c1df13d847
2024-10-07 11:41:07 #17 0x55c1df14d243
2024-10-07 11:41:07 #18 0x7f358377d609 start_thread
Подробнее здесь: https://stackoverflow.com/questions/790 ... ing-proxys
Настройка Selenium Wire/Grid в ошибке Docker при использовании прокси ⇐ Python
Программы на Python
1728473460
Anonymous
Я пытаюсь настроить свой небольшой сканер как проект Docker. Я использую Selenium Wire, поэтому могу запускать более одного запроса одновременно. Однако теперь я хочу настроить прокси-сервер и столкнулся с несколькими проблемами.
Вот мой код:
Requirement.txt< /p>
selenium==4.0.0
selenium-wire==5.1.0
blinker==1.7.0
setuptools==74.0.0
requests
fake_useragent==1.5.1
Мой файл Docker-Compose:
Docker-Compose
version: '3'
services:
chrome:
image: selenium/node-chrome:4.10.0
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=10
networks:
- selenium-network
selenium-hub:
image: selenium/hub:4.10.0
container_name: selenium-hub
ports:
- "4444:4444"
networks:
- selenium-network
python-app:
build:
context: .
dockerfile: Dockerfile.future
depends_on:
- selenium-hub
networks:
- selenium-network
networks:
selenium-network:
driver: bridge
Dockerfile.future
FROM python
WORKDIR /
COPY requirements.txt .
COPY test_with_futures.py .
RUN pip install -r requirements.txt
CMD ["python", "test_with_futures.py"]
и мой код Python "Test_with_futures.py"
print("Docker gestartet")
import time
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
import concurrent
from fake_useragent import UserAgent
from random import random
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def call_function():
try:
# PROXY SETTINGS
PROXY = f"http://USER:PW@de.smartproxy.com:20000"
desired_capabilities = DesiredCapabilities.CHROME.copy() # Necessary cause it wants t use Firefox.
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument(f'--proxy-server={PROXY}') # If i dont use this, there Proxy will not be used, everthing will happen with my own IP.
# Setzen des Proxys in den Selenium Wire Optionen
seleniumwire_options = {
'auto_config': False,
'proxy': {
'http': PROXY,
'https': PROXY
}
}
driver = webdriver.Remote(
command_executor="http://selenium-hub:4444/wd/hub",
options=chrome_options,
seleniumwire_options=seleniumwire_options,
desired_capabilities=desired_capabilities
)
print("----------------- AKTUELLER PROXY -------------------------------------------")
print(driver.proxy)
print("------------------------------------------------------------")
driver.get("https://ip.smartproxy.com/json")
wait = WebDriverWait(driver, 50) # Warte bis zu 50 Sekunden
pre_element = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/pre")))
res = pre_element.text
print("----------------- DRIVER -----------------------------------")
print(res)
print("------------------------------------------------------------")
return "", "" # Not used at the moment
except Exception as e:
print(e)
finally:
driver.quit()
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
futures = []
for i in range(0, 5):
print(f"Webseitenindex {i}")
future = executor.submit(call_function)
futures.append(future)time.sleep(1)
for future in futures:
ipv4_value, ipv6_value = future.result() # Entpacken des Tupleprint(f"IPv4: {ipv4_value}, IPv6: {ipv6_value}")
Can someone help me please?
Вот сообщение об ошибке, которое я получаю:
2024-10-07 11:41:07 Message:
2024-10-07 11:41:07 Stacktrace:
2024-10-07 11:41:07 #0 0x55c1df1544e3
2024-10-07 11:41:07 #1 0x55c1dee83c76
2024-10-07 11:41:07 #2 0x55c1deebfc96
2024-10-07 11:41:07 #3 0x55c1deebfdc1
2024-10-07 11:41:07 #4 0x55c1deef97f4
2024-10-07 11:41:07 #5 0x55c1deedf03d
2024-10-07 11:41:07 #6 0x55c1deef730e
2024-10-07 11:41:07 #7 0x55c1deedede3
2024-10-07 11:41:07 #8 0x55c1deeb42dd
2024-10-07 11:41:07 #9 0x55c1deeb534e
2024-10-07 11:41:07 #10 0x55c1df1143e4
2024-10-07 11:41:07 #11 0x55c1df1183d7
2024-10-07 11:41:07 #12 0x55c1df122b20
2024-10-07 11:41:07 #13 0x55c1df119023
2024-10-07 11:41:07 #14 0x55c1df0e71aa
2024-10-07 11:41:07 #15 0x55c1df13d6b8
2024-10-07 11:41:07 #16 0x55c1df13d847
2024-10-07 11:41:07 #17 0x55c1df14d243
2024-10-07 11:41:07 #18 0x7f358377d609 start_thread
Подробнее здесь: [url]https://stackoverflow.com/questions/79061630/setup-selenium-wire-grid-in-docker-error-when-using-proxys[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия