Linux 上的浏览器 headful 模式用于网页抓取

问题描述 投票:0回答:1

https://swappie.com/en/iphone/ 如果我们在 headful 模式下使用 proxybrowser(两者都是在 Selenium 和 Chromium 中使用 Chrome headless),我们就能绕过 Cloudflare 保护页面 在剧作家中)。但在 Linux 服务器上,我们只能以无头方式运行浏览器。
你有什么想法如何突破吗?

selenium-webdriver web-scraping browser playwright bypass
1个回答
0
投票

有一个名为

Xvfb
的 Linux 工具,它可以创建一个虚拟显示器,这样你在其中运行浏览器测试时就不必使用 Chrome 的无头模式。各种框架都可以选择使用它。

这是一个示例 SeleniumBase 脚本,它绕过热门网站上的 Cloudflare Turnstile 页面:

"""SB Manager using UC Mode for evading bot-detection."""
from seleniumbase import SB

with SB(uc=True, test=True, xvfb=True) as sb:
    sb.driver.uc_open_with_reconnect("https://top.gg/", 5)
    if not sb.is_text_visible("Discord Bots", "h1"):
        sb.driver.uc_open_with_reconnect("https://top.gg/", 5)
    sb.assert_text("Discord Bots", "h1", timeout=3)
    sb.highlight("h1", loops=3)
    sb.set_messenger_theme(location="top_center")
    sb.post_message("Selenium wasn't detected!", duration=3)

它也适用于 Linux(假设您的 IP 地址尚未被阻止)。

© www.soinside.com 2019 - 2024. All rights reserved.