Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Problem to run code from terminal #728

Open
MarcelSuleiman opened this issue Nov 25, 2023 · 0 comments
Open

Problem to run code from terminal #728

MarcelSuleiman opened this issue Nov 25, 2023 · 0 comments

Comments

@MarcelSuleiman
Copy link

MarcelSuleiman commented Nov 25, 2023

Hi, I have simple code:

from seleniumwire import webdriver
# from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options


with open("file-3.txt") as f:
	 proxies = [line.rstrip() for line in f]


chrome_options = Options()
chrome_options.add_argument('--blink-settings=imagesEnabled=false')
chrome_options.add_argument("--window-size=650,900")
chrome_options.add_argument('--allow-running-insecure-content')
# chrome_options.add_argument("--start-maximized")


proxy_count = 0
for row, proxy_line in enumerate(proxies):

	data = proxy_line.split(":")

	PROXY_HOST = data[0]
	PROXY_PORT = data[1]
	PROXY_USER = data[2]
	PROXY_PASS = data[3]

	options = {
		'proxy': {
			'https': f'https://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}',
		}
	}

	driver = webdriver.Chrome(seleniumwire_options=options, options=chrome_options)
	driver.get('https://mojaipadresa.sk/sk')

	proxy_ip = driver.find_element(By.CLASS_NAME, "ip-address").text
	print(proxy_ip)
	proxy_count += 1

	if proxy_count == 1:
		break

file-3.txt include some proxies (example):

ip:port:user:pass
ip:port:user:pass

when I run code from IDE (sublimetext) - works well
but, when I go to my folder via terminal and run python3 main.py it will crach.

marcel@marcel-Latitude-5501:~/Documents/projects/slenium_proxy_test$ python3 main.py
127.0.0.1:57756: Traceback (most recent call last):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py", line 113, in handle
    root_layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py", line 23, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py", line 285, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in __call__
    if not self._process_flow(flow):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 270, in _process_flow
    if self.mode is HTTPMode.upstream and self.should_bypass_upstream_proxy(f.request):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 556, in should_bypass_upstream_proxy
    no_proxy = int(port[0]) == request.port
ValueError: invalid literal for int() with base 10: ''

127.0.0.1:57770: Traceback (most recent call last):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py", line 113, in handle
    root_layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py", line 23, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py", line 285, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in __call__
    if not self._process_flow(flow):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 270, in _process_flow
    if self.mode is HTTPMode.upstream and self.should_bypass_upstream_proxy(f.request):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 556, in should_bypass_upstream_proxy
    no_proxy = int(port[0]) == request.port
ValueError: invalid literal for int() with base 10: ''

127.0.0.1:57782: Traceback (most recent call last):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py", line 113, in handle
    root_layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py", line 23, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py", line 285, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in __call__
    if not self._process_flow(flow):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 270, in _process_flow
    if self.mode is HTTPMode.upstream and self.should_bypass_upstream_proxy(f.request):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 556, in should_bypass_upstream_proxy
    no_proxy = int(port[0]) == request.port
ValueError: invalid literal for int() with base 10: ''

127.0.0.1:57790: Traceback (most recent call last):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py", line 113, in handle
    root_layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py", line 23, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py", line 285, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in __call__
    layer()
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in __call__
    if not self._process_flow(flow):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 270, in _process_flow
    if self.mode is HTTPMode.upstream and self.should_bypass_upstream_proxy(f.request):
  File "/home/marcel/.local/lib/python3.10/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 556, in should_bypass_upstream_proxy
    no_proxy = int(port[0]) == request.port
ValueError: invalid literal for int() with base 10: ''

chrome version: 119
selenium: 4.15.2
selenium-wire: 5.1.0
Ubuntu 20.04

Any idea what is wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant