English 中文(简体)
如何利用Selenium网站浏览
原标题:How to webscrape this website using Selenium
The bounty expires in 6 days. Answers to this question are eligible for a +50 reputation bounty. Mateo is looking for an answer from a reputable source.

我想将网站。 以下是我提出的法典。 可悲的是,我看到了我所尝试的99%时间的上限。 有些人可以 h住我可以补充的法典,或者我如何能够修改该法典,以便改进这一规范,避免被发现。

增 编

from selenium import webdriver
import undetected_chromedriver as uc
import time
import random

# Initialize undetected ChromeOptions
chrome_options = uc.ChromeOptions()

# Essential options to avoid detection
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--incognito")

# Correctly setting excludeSwitches within undetected_chromedriver context
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--start-maximized")  # To start maximized
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option( useAutomationExtension , False)

# Rotating User-Agent
user_agents = [
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
    # Add more as needed
]
random_user_agent = random.choice(user_agents)
chrome_options.add_argument(f"user-agent={random_user_agent}")

# Adjusting viewport size to non-standard dimensions if needed
# chrome_options.add_argument("--window-size=1366,768")  # Use only if you don t want to start maximized

# Use undetected_chromedriver to avoid detection
driver = uc.Chrome(options=chrome_options)

# Open the specified website
driver.get("https://www.rome2rio.com/map/Marseille/Paris")

# Mimicking human behavior with random sleep
time.sleep(random.uniform(2, 4))

# Proceed with your script...

# Close the driver after operations are complete
driver.quit()
问题回答




相关问题
Multiple Forms With Captcha - Error on Ajax Submit

Problem: I have a comment page with each comment box having a reply button. Now the reply buttons have a jquery live click binding on them which when triggered loads the appropriate comment form via ...

reCAPTCHA-like Web Service in other Languages

Is there a CAPTCHA web service like reCAPTCHA that supports languages other than English? It would be nice to have localized CAPTCHAs for non-English users.

Cucumber tests and captcha: how to handle that?

We are considering using Cucumber for testing web applications (not in rails, most of them are asp.net actually). The applications are in production, our main goal is to test if everything is fine ...

zend_captcha always fails isValid()

I ve got an issue with Zend_Captcha always returning false when the page is submitted and the captcha s isValid() method is being called. It s driving my nuts because this as far as I am concerned ...

Custom captcha design

I currently ran into the issue that I do not have the money to buy/rent any professional captchaing service. So I tried to look around for OS captcha generators, and captcha designs. I also had a ...

Zend_Form_Element_Captcha - Reload

how could I add a "reload captcha"-feature? How I could change the image element with JavaScript I know, but how should I manage that with the ZF? I generate the captcha with Zend_Form_Element_Captcha ...

Captcha reloading and animated icon synchronization problem

I want to create a captcha in my website. I will try to describe how I want to do that. See the code below please: <img src=”captcha_img.png”> <img src=”reload.png”> <a href=”..”>...

How to write the Captcha?

I am developing a registration form in that i want to place the CAPTCHA . i generate a random string but how to convert that into the image other wise how can i develop the CAPTCHA code or any ...

热门标签