kaliiiiiiiiii / Selenium-Profiles

undetected Selenium using chromedriver and emulation / device profiles
Other
272 stars 29 forks source link

userAgent brand reg match with error #78

Closed daixiongfei888 closed 1 year ago

daixiongfei888 commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce

execute the test code, and it encountered the following error:
re.error: bad character range :-. at position 7

# python-code

original code from script\profiles.py brandspattern = r'^Not[ (:-./);=?]A[ (:-./);=?_]Brand$'

brandspattern = r'^Not[ (:./);=?]A[ (:./);=?_]Brand$'

Expected behavior or error-message A clear and concise description of what you expected to happen.

# error-message

File "/Users/xfdai/PycharmProjects/Selenium-Profiles/src/selenium_profiles/webdriver.py", line 156, in init self.profiles.cdp_handler.apply(cdp_profile=profile["cdp"]) File "/Users/xfdai/PycharmProjects/Selenium-Profiles/src/selenium_profiles/scripts/profiles.py", line 40, in apply useragent = self.set_useragent(profile["useragent"], patch_version=profile["patch_version"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xfdai/PycharmProjects/Selenium-Profiles/src/selenium_profiles/scripts/profiles.py", line 78, in set_useragent useragent = self.patch_version(useragent_profile=useragent, version=patch_version, driver=self._driver) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xfdai/PycharmProjects/Selenium-Profiles/src/selenium_profiles/scripts/profiles.py", line 118, in patch_version if not re.match(brands_pattern, brand["brand"]): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/init.py", line 166, in match return _compile(pattern, flags).match(string) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/init.py", line 294, in _compile p = _compiler.compile(pattern, flags) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_compiler.py", line 743, in compile p = _parser.parse(p, flags) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 980, in parse p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 455, in _parse_sub itemsappend(_parse(source, state, verbose, nested + 1, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 612, in _parse raise source.error(msg, len(this) + 1 + len(that)) re.error: bad character range :-. at position 7

Environment (please complete the following information):

Additional context Add any other context about the problem here.

kaliiiiiiiiii commented 1 year ago

@daixiongfei888 plase provide

kaliiiiiiiiii commented 1 year ago

Closing because of inactivity, feel free to comment if it still persists