seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.46k stars 909 forks source link

Time Zone Based on IP ,Time Zone,Time From IP,Time From Javascript #2790

Closed xipeng5 closed 1 month ago

xipeng5 commented 1 month ago

IP based time zone, local time zone, IP based time, local time, WebGL, WebGL Report, WebGPU Report,

some issues were found. Unable to set these parameters on your own. Some parameters, such as WebGL, WebGL Report, and WebGPU Report, are fixed and cannot be randomly generated every time the target website is visited

image image

And in UC mode, the xpath uc selector cannot be used image

mdmintz commented 1 month ago

All fingerprint masking is done via the external selenium-stealth integration: https://github.com/seleniumbase/SeleniumBase/issues/2404#issue-2061185101

However, there are ways to change properties via execute_cdp_cmd: (As mentioned in https://github.com/seleniumbase/SeleniumBase/issues/918#issuecomment-864054769)

tz_params = {'timezoneId': 'America/New_York'}
driver.execute_cdp_cmd('Emulation.setTimezoneOverride', tz_params)

(Note that you'll likely need to load the page first, then call the driver.execute_cdp_cmd command, and then refresh the page for the settings to take effect. Calling the uc_open methods will reset settings made be driver.execute_cdp_cmd.)

And as mentioned in https://github.com/seleniumbase/SeleniumBase/issues/2658#issuecomment-2035000001, uc_click() requires JS, which needs selectors to be in CSS Selector format. Use a CSS Selector instead, or a valid XPath that has a CSS Selector equivalent. Not all XPaths can be directly translated into matching CSS Selectors, but all elements can be expressed via CSS Selector, so just give it a CSS Selector directly instead.

xipeng5 commented 1 month ago

Thank you very much for your reply. Your library has benefited me greatly. Sincerely thank you, but I have encountered some issues. I tried to register an account using your library, but every time it failed. I used a proxy IP and set the browser's fingerprint and other parameters, but none of them worked. I don't know where the problem is. If it doesn't take up your time, I hope you can help me take a look at the code. Below is the code snippet link. Thank you very much and I wish you a happy life。https://github.com/xipeng5/testap/blob/main/test.py

mdmintz commented 1 month ago

SeleniumBase UC Mode doesn't do fingerprint alteration. It makes your browser appear as though a human is controlling it, rather than Selenium. The browser fingerprint will be the same as if a human navigated to a website from that network. For fingerprint alterations, you'll need to use external libraries, such as https://github.com/diprajpatra/selenium-stealth. You might also find answers on https://stackoverflow.com/.

xipeng5 commented 1 month ago

Thank you very much for your reply. My English level is not very good. I will use a translator to complete the conversation with you. If there is anything offensive in my language, please understand. Regarding your suggestion of using selenium Stealth to create fingerprints, I will try it later. I would like to ask you a question as you have done so many automated scripts. What do you think is the core issue with my account registration? Do you think setting up a fingerprint proxy will solve the difficulties I am currently facing? Thank you for your reply. Looking forward to communicating with you

mdmintz commented 1 month ago

Using a proxy can help. proxy=username:password:host:port or proxy=host:port to set one with SeleniumBase. I don't know about fingerprint modification, so I can't help there. That's why I recommended using an external library for that, such as https://github.com/diprajpatra/selenium-stealth. SeleniumBase UC Mode makes your Selenium browser appear the same as a regular web browser. If you run into issues on a website when using a regular browser, then it could be that your IP Address was blocked.

xipeng5 commented 1 month ago

Thank you very much for your reply. I will try what you said and then come back to ask for your advice