-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting ready for the next UC Mode video tutorial #2478
Comments
More things to cover: 📗 What is Rosetta 2 and why might macOS users care? Rosetta 2 lets you run an Intel-based For macOS users, it's easy to get it if you don't already have it: softwareupdate --install-rosetta 📗 In the previous tutorial, only Chrome was supported in UC Mode. Now, two more browsers are supported! 📗 Make sure that people realize that if the same IP Address hits a website too many times, then that IP Address could be blocked, even if that site can't detect that you're using a bot. (This is one reason why some people use proxies / rotating proxies.) |
📗 If there's time, also cover how to properly do multithreaded UC Mode without (Hint: Need to include Sample script using import sys
from concurrent.futures import ThreadPoolExecutor
from seleniumbase import Driver
sys.argv.append("-n") # Tell SeleniumBase to do thread-locking as needed
def launch_driver(url):
driver = Driver(uc=True)
try:
driver.get(url=url)
driver.sleep(2)
finally:
driver.quit()
urls = ['https://seleniumbase.io/demo_page' for i in range(3)]
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
for url in urls:
executor.submit(launch_driver, url) Here's the script from above with randomized window placement so that the windows don't overlap: import sys
from concurrent.futures import ThreadPoolExecutor
from random import randint
from seleniumbase import Driver
sys.argv.append("-n") # Tell SeleniumBase to do thread-locking as needed
def launch_driver(url):
driver = Driver(uc=True)
try:
x, y, w, h = randint(0, 755), randint(38, 403), 900, 600
driver.set_window_rect(x, y, w, h)
driver.get(url=url)
driver.sleep(2)
finally:
driver.quit()
urls = ['https://seleniumbase.io/demo_page' for i in range(3)]
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
for url in urls:
executor.submit(launch_driver, url) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Note: This thread is specifically for documenting steps for the next UC Mode video tutorial. Update: Repeat offenders will be blocked. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Video is ready! |
Getting ready for the next UC Mode video tutorial
If you haven't already heard the news, the last one was quite popular:
Thousands of views, hundreds of likes, and people want to see more.
(Here's the GitHub ticket for the previous video: #2213)
Now comes the time to plan the next one. There are lot of things that I didn't get to cover last time. I'll start a list:
📗 People wanted more information about the renamed Chrome console variables that appear when chromedriver launches Chrome. This is quite easy to show in a screenshot:
If you use regular Selenium/WebDriver to launch Chrome, those variables appear in the console. It's one of the easiest ways for websites to detect Selenium. In UC Mode, those variables are renamed/removed.
📗 Since the previous tutorial, more examples have been added:
In particular, those example deal with a different type of CloudFlare CAPTCHA: One where all users must click the box (generally after filling out a form) in order to proceed. The first video covered the CAPTCHA that only appears when you initially load a page. Only traffic detected as bot-traffic would be stopped by it. With the form CAPTCHA, everyone has to click the box (even if Cloudflare thinks you're human) so it has to be handled in a different/special way.
📗 The previous tutorial did not cover all the differences between the
Driver(uc=True)
andSB(uc=True)
formats. People need to know when they should useSB()
instead ofDriver()
. In particular, theSB()
format does a lot more, and has a lot more methods. For instance, theSB()
format will automatically close the driver for you at the end of the test or code block, whereas in theDriver()
format, the user needs to calldriver.quit()
in the script. Not doing that would cause a memory leak, which gets you detected. Also, theSB()
format also automatically handles virtual displays for environments with no GUI. With theDriver()
format, users may need to add in something likesbvirtualdisplay
themselves if they want to run on certain Linux environments while remaining undetected.📗 Since the previous tutorial, a new way has been added in so that you can easily combine automation with manual intervention in UC Mode in such a way that it keeps your browser undetected. Here are a few examples of that:
It's important to note that while in that special
breakpoint()
, websites can't detect you, but it also means that you can't call any Selenium commands until after you've left thebreakpoint()
. (More info on that here: #2384)📗 People want to see more live demos using sites with non-Cloudflare protection. (The previous live demos mainly covered Cloudflare-protected sites.)
📗 People also commented on the video clips (mainly of Star Trek actors) that were embedded in the full video for entertainment value and highlighting important points. There seemed to be a love/hate reaction to that, where some people really enjoyed them, while others saw it as a distraction. Based on YouTube's apparent algorithm, adding small clips into a video like that seems to make videos far more likely to appear in the Suggested Videos section of other videos, which greatly increases the number of people who find out about a video and watch it. At least for the time being, my channel and videos can really benefit from any marketing assistance that they can get... which means the video clips will continue for now, but I'll try using fewer of them in total. (To the person who said Christopher Lloyd wasn't in Star Trek... Please watch Star Trek III: The Search for Spock... Lloyd was the main villain!)
📗 People were wondering how to combine UC Mode with Wire Mode so that the browser remains undetected while still being able to see the requests being made. (The two modes cannot be used together.) Wire Mode uses an unmodified
selenium-wire
for that, so there's not much that can be done there unlessselenium-wire
makes changes to their repo to support that. To make matters worse, "Selenium Wire is no longer being maintained" according to their repo. (They announced that in January 2024). The good news is that alternatives exist, eg: SeleniumBase/examples/uc_cdp_events.py, which demonstrates how to collect CDP events from the browser. Additionally, I'm working on aselenium-wire
alternative that allows you to see browser requests (and still be compatible with UC Mode).📗 People also want to know how to record automation scripts while using UC Mode. Just start the Recorder like this:
Additionally, you can activate the Recorder in the middle of a script like this:
self.activate_recorder()
📗 There's also a new UC Mode section in the SeleniumBase Docs: SeleniumBase/help_docs/uc_mode.md
Looks like there are lots of things to cover in the next UC Mode video tutorial. Get ready to be ready!
The text was updated successfully, but these errors were encountered: