selenium wire proxy

proxy ของ Selenium Wire เป็นทางลัดที่สุดสำหรับทำ browser automation ที่ยืนยันตัวตนใน Python เพราะ Selenium Wire รับ proxy URL แบบ login:password ได้โดยตรงใน option เดียว แทนที่จะต้องใช้วิธีแก้ปัญหาด้วย extension ที่ Selenium ปกติต้องใช้ นอกจากนี้ยังแสดง HTTP request และ response ทุกรายการที่ browser สร้าง จึงเป็นเหตุผลที่ทีม scraper และ QA เลือกใช้

คู่มือนี้อธิบายครบทุกขั้นตอน ครอบคลุมการติดตั้งและตรึงเวอร์ชันของ library อย่างปลอดภัย การเชื่อมต่อ proxy ที่ยืนยันตัวตน การตรวจสอบ exit IP การตรวจสอบและรอ request การแก้ไข headers การสลับ IP การทำงานแบบ headless การลดการใช้หน่วยความจำ การจัดการ certificate ของ HTTPS อย่างตรงไปตรงมา การใช้ร่วมกับ undetected-chromedriver และทางเลือกสมัยใหม่ที่เหมาะสม

DataImpulse เป็นผู้ให้บริการ proxy ที่มีจริยธรรม โดยมี residential, mobile และ datacenter IP มากกว่า 90 ล้านรายการใน 195 ประเทศ ใช้รูปแบบจ่ายตามการใช้งานเริ่มต้น 1 ดอลลาร์ต่อ GB พร้อม traffic ที่ไม่หมดอายุ และใช้สำหรับ web scraping, ad verification, การติดตามราคา, การวิจัยตลาด และการจัดการหลายบัญชี

ข้อมูลสำคัญ

  • proxy ของ Selenium Wire: Selenium Wire รับ proxy URL แบบ login:password โดยตรงใน seleniumwire_options ทำให้ browser automation ที่ยืนยันตัวตนทำงานได้โดยไม่ต้องใช้วิธีแก้ปัญหาด้วย extension ที่ Selenium ปกติต้องใช้
  • ประเภท proxy ที่ดีที่สุด: residential proxy แบบหมุนเวียน ซึ่งใช้ IP ของผู้บริโภคจริงที่หลบเลี่ยงการตรวจจับได้
  • ราคา: เริ่มต้น 1 ดอลลาร์ต่อ GB จ่ายตามการใช้งาน พร้อม traffic ที่ไม่หมดอายุและไม่มีค่าสมาชิก
  • ความครอบคลุม: IP ที่จัดหาตามหลักจริยธรรมมากกว่า 90M ใน 195 ประเทศ
  • ความน่าเชื่อถือ: อัตราสำเร็จ 99.51% ได้คะแนน 4.8 จาก 5 บน G2
  • โปรโตคอลและการกำหนดเป้าหมาย: HTTP, HTTPS และ SOCKS5 พร้อมการกำหนดเป้าหมายตามประเทศ
กำหนดเส้นทาง Selenium Wire ผ่าน proxy

Selenium Wire คืออะไร และยังมีการดูแลอยู่หรือไม่?

Selenium Wire คือ Python library ที่ขยาย Selenium เพื่อให้ script ตรวจสอบ รอ และแก้ไข HTTP request และ response ของ browser ได้ และเพิ่มการรองรับ proxy ที่ยืนยันตัวตนโดยตรง โดยทำงานผ่าน local man-in-the-middle proxy ที่ browser ถูกชี้ไปหา แล้วส่งต่อ traffic ไปยัง upstream proxy จริง

ข้อควรระวังตามจริงคือโครงการต้นฉบับถูกเก็บถาวรและไม่มีการดูแลเชิงรุกแล้ว แม้ยังทำงานได้ดีใน production แต่ควรตรึงเวอร์ชันและทดสอบการอัปเกรด Selenium, Chrome หรือ dependency แต่ละครั้งแยกต่างหากก่อนนำไปใช้ มี community fork ที่นำการแก้ไขความเข้ากันได้ไปต่อ และตารางเปรียบเทียบในคู่มือนี้จะแสดงว่ากรณีใดเครื่องมือที่ยังดูแลอยู่ เช่น Playwright เป็นทางเลือกที่ดีกว่าในระยะยาว

เหตุผลที่ทีมยังเลือกใช้คือความสะดวก หากมีชุดทดสอบ Selenium หรือ scraper อยู่แล้ว การเพิ่ม Selenium Wire เปลี่ยนเพียง import หนึ่งบรรทัดพร้อม proxy option และได้ทั้งการรองรับ proxy ที่ยืนยันตัวตนกับความสามารถในการอ่าน request ทุกรายการของหน้า การสร้างการมองเห็นระดับ request นี้ใหม่บน Selenium ปกติต้องใช้ความพยายามมาก ดังนั้นสำหรับ codebase เดิมจึงมักคุ้มแม้สถานะจะถูกเก็บถาวร หากเพิ่งเริ่มใช้ browser จริงเพื่อเก็บข้อมูล คู่มือเรื่อง วิธี scrape หน้าเว็บแบบ dynamic อธิบายภาพรวมของการ render และช่วงเวลาที่จำเป็นต้องใช้ browser

จะติดตั้ง Selenium Wire และตรึงเวอร์ชันเพื่อเลี่ยงปัญหาได้อย่างไร?

ติดตั้ง selenium-wire ควบคู่กับ selenium และตรึง blinker ให้ต่ำกว่า 1.8 เพราะ release นั้นลบชื่อภายในที่ Selenium Wire import ตอนเริ่มต้น เนื่องจากโครงการถูกเก็บถาวร dependency ที่ปล่อยให้ลอยเวอร์ชันคือสาเหตุที่พบบ่อยที่สุดที่ทำให้การตั้งค่าซึ่งเคยทำงานล้มเหลวกะทันหัน

ความล้มเหลวแบบคลาสสิกคือ ImportError ของ WeakNamespace หลัง blinker อัปเกรดอัตโนมัติ การตรึงเวอร์ชันช่วยเลี่ยงได้:

# Selenium Wire is archived. Pin known-good versions so an upstream release
# does not break your build overnight.
#
# blinker >= 1.8 removed blinker._saferef / WeakNamespace, which Selenium Wire
# imports at startup. On blinker 1.8+ you get:
#   ImportError: cannot import name 'WeakNamespace' from 'blinker'
# The fix is to hold blinker below 1.8.
pip install "selenium-wire==5.1.0" "selenium==4.9.1" "blinker==1.7.0"

# Selenium Wire also depends on brotli and can trip on very new Selenium.
# If you must run current Selenium, test in a throwaway virtualenv first, or
# move to a maintained fork such as selenium-wire-2 that tracks these fixes.

เก็บ version pin เหล่านี้ในไฟล์ requirements เพื่อให้ continuous integration และเพื่อนร่วมทีมได้ชุดเวอร์ชันที่พิสูจน์แล้วว่าใช้งานได้เหมือนกัน เมื่อต้องการย้ายไปใช้ Selenium เวอร์ชันปัจจุบัน ให้ถือเป็นการอัปเกรดโดยเจตนาที่มีการทดสอบของตนเอง แทนที่จะปล่อยให้ pip เลือกเวอร์ชันล่าสุดของทุกอย่าง

ตั้งค่า proxy ที่ยืนยันตัวตนใน Selenium Wire อย่างไร?

ส่ง dictionary ของ proxy ภายใน seleniumwire_options ตอนสร้าง driver โดยฝัง username และ password ไว้ใน URL และยกเว้น localhost ผ่าน no_proxy นี่คือฟีเจอร์หลักที่ทำให้ Selenium Wire เหมาะกว่าการใช้ Selenium ปกติสำหรับงาน proxy

import webdriver จาก seleniumwire ไม่ใช่จาก selenium แล้วส่ง options ให้ credentials, host และ port มาจาก dashboard ของผู้ให้บริการ สำหรับ DataImpulse host คือ gw.dataimpulse.com และ port คือ 823:

from seleniumwire import webdriver  # import from seleniumwire, not selenium

proxy_url = "http://login:[email protected]:823"

seleniumwire_options = {
    "proxy": {
        "http": proxy_url,
        "https": proxy_url,
        "no_proxy": "localhost,127.0.0.1",
    }
}

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)
driver.get("https://example.com")
print(driver.title)
driver.quit()

รายการ no_proxy ทำให้ที่อยู่ local ไม่ผ่าน proxy เพื่อให้ driver ติดต่อ ChromeDriver ได้โดยตรง หากการยืนยันตัวตนผิด โดยทั่วไปจะเห็น response 407; บทความเรื่อง ข้อผิดพลาด 407 Proxy Authentication Required อธิบายวิธีวิเคราะห์ปัญหา สำหรับข้อมูลพื้นฐานเกี่ยวกับการทำงานของ proxy ที่ใช้ credentials โดยทั่วไป ดู residential proxies.

ตรวจสอบว่า exit IP ของ proxy ทำงานอยู่ได้อย่างไร?

ให้ driver เปิด endpoint สะท้อน IP เช่น api.ipify.org แล้วตรวจว่าที่อยู่ที่ตอบกลับเป็นของ proxy ไม่ใช่เครื่องของคุณเอง อย่าคิดว่า proxy ทำงานแล้วเพียงเพราะหน้าโหลดได้

import json
from seleniumwire import webdriver

proxy_url = "http://login:[email protected]:823"
seleniumwire_options = {
    "proxy": {"http": proxy_url, "https": proxy_url,
              "no_proxy": "localhost,127.0.0.1"}
}

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)
driver.get("https://api.ipify.org/?format=json")

body = driver.find_element("tag name", "body").text
exit_ip = json.loads(body)["ip"]
print("Exit IP:", exit_ip)  # should be the proxy, not your own address

driver.quit()

หาก response แสดง IP จริงของคุณ มี 3 จุดที่ควรตรวจสอบ: no_proxy ไม่ได้ match กับเป้าหมายโดยไม่ตั้งใจ, credentials ถูกต้อง และคุณ import webdriver จาก seleniumwire ให้ทำการตรวจนี้เป็นขั้นตอนแรกของงานใหม่ทุกงาน และทำซ้ำหลังเปลี่ยนการตั้งค่า proxy

จะตรวจสอบและรอ request ที่ต้องการได้อย่างไร?

อ่าน driver.requests เพื่อไล่ดู request และ response ทุกรายการที่ browser สร้าง และใช้ driver.wait_for_request เพื่อรอจนมี call ที่ตรงกัน ความสามารถนี้ทำให้ Selenium Wire ต่างจาก WebDriver ปกติ และมีคุณค่าอย่างมากในการค้นหา JSON API ที่อยู่เบื้องหลังหน้าเว็บ

from seleniumwire import webdriver

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)
driver.get("https://example.com/products")

# Block until a request whose URL matches the regex is captured.
request = driver.wait_for_request(r"/api/v2/products", timeout=15)
print(request.method, request.url)
print("Status:", request.response.status_code)
print("Type:", request.response.headers["Content-Type"])

# Walk every captured request/response pair the browser made.
for r in driver.requests:
    if r.response:
        print(r.response.status_code, r.url)

driver.quit()

การเรียก wait_for_request รับ regular expression ที่ match กับ URL และคืนค่าทันทีที่จับ request ได้ จึงไม่ต้องใช้การหน่วงเวลาแบบกำหนดตายตัวที่เปราะบาง เมื่อรู้ว่า background call ใดมีข้อมูล คุณมักข้ามการ render ทั้งหมดและเรียก endpoint นั้นโดยตรงได้ ซึ่งประหยัดกว่ามาก เทคนิคนี้เป็นหัวใจของ แนวทางปฏิบัติที่ดีสำหรับ web scraping.

จะแก้ไข request headers ด้วย interceptor ได้อย่างไร?

กำหนด function ให้ driver.request_interceptor แล้วมันจะทำงานก่อน request แต่ละรายการออกจาก browser ทำให้เขียนทับ headers แทรก token หรือตัด parameter ได้ การตั้งค่า User-Agent และภาษาให้ดูสมจริงเป็นเหตุผลทั่วไปที่ใช้วิธีนี้

from seleniumwire import webdriver

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)

def interceptor(request):
    # Delete first, then set, so you replace the header instead of duplicating it.
    del request.headers["User-Agent"]
    request.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
    request.headers["Accept-Language"] = "en-US,en;q=0.9"

driver.request_interceptor = interceptor
driver.get("https://httpbin.org/headers")
print(driver.find_element("tag name", "body").text)
driver.quit()

ลบ header เดิมก่อนตั้งค่าใหม่ มิฉะนั้น Selenium Wire อาจส่งทั้งค่าเดิมและค่าที่แทนที่ response_interceptor ที่สอดคล้องกันช่วยให้อ่านหรือเขียน response ใหม่ได้ ให้ interceptor ทำงานเบา ๆ เพราะมันทำงานกับทุก request รวมถึงรูปภาพและ script headers ที่สอดคล้องและดูเป็นมนุษย์เป็นสัญญาณที่ไม่เด่นชัดประการหนึ่งใน แนวทางปฏิบัติที่ดีสำหรับ web scraping.

จะหมุนเวียน proxy ต่อ request ใน Selenium Wire ได้อย่างไร?

มี 2 รูปแบบ: กำหนด driver.proxy ใหม่ขณะทำงานเพื่อสลับ configuration บน browser เดิม หรือสร้าง driver ใหม่เมื่อต้องการ profile และ cookie jar ที่สะอาดด้วย gateway แบบหมุนเวียนอย่าง DataImpulse จะให้ residential exit ใหม่เมื่อมี connection ใหม่อยู่แล้ว ดังนั้นงานส่วนใหญ่เพียงสลับ configuration สำหรับประเทศอื่น

from seleniumwire import webdriver

base = "http://login:[email protected]:823"
opts = {"proxy": {"http": base, "https": base,
                  "no_proxy": "localhost,127.0.0.1"}}
driver = webdriver.Chrome(seleniumwire_options=opts)

# Option A: reassign driver.proxy at runtime to switch config (for example a
# different country gateway) without rebuilding the browser. Cheap and fast.
uk = "http://login:[email protected]:823"
driver.proxy = {"http": uk, "https": uk, "no_proxy": "localhost,127.0.0.1"}
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

# Option B: recreate the driver per job when you need a guaranteed clean
# browser profile and cookie jar as well as a fresh exit IP.
def fresh_driver():
    return webdriver.Chrome(seleniumwire_options=opts)

for _ in range(3):
    d = fresh_driver()
    d.get("https://api.ipify.org")
    print(d.find_element("tag name", "body").text)
    d.quit()

การกำหนด driver.proxy ใหม่มีต้นทุนต่ำและทำให้ browser ยังอุ่นอยู่ เหมาะกับ loop ปริมาณมากที่ต้นทุนเริ่มต้นเป็นส่วนหลัก การสร้าง driver ใหม่หนักกว่าแต่รับประกันการแยกงาน ซึ่งสำคัญเมื่อเป้าหมายผูก session กับ cookies และ local storage รวมถึง IP เลือกตามว่าต้องการตัวตนสะอาดหรือเพียงที่อยู่ใหม่ กฎใช้งานจริงคือกำหนด proxy ใหม่ขณะเก็บหน้าสาธารณะโดยไม่ระบุตัวตน และสร้าง driver ใหม่ทุกครั้งที่ข้ามขอบเขตบัญชีหรือ login เพื่อไม่ให้ cookie ที่รั่วจากรอบหนึ่งตามไปอีกรอบ เป้าหมายบน mobile ที่ fingerprint อย่างเข้มงวดมักเหมาะกับ mobile proxies สำหรับกรณีที่ยากที่สุด ขณะที่หน้าที่เบากว่ายังใช้ exit ที่มีต้นทุนต่ำกว่าได้

จะรัน Selenium Wire แบบ headless และใช้หน่วยความจำต่ำได้อย่างไร?

เพิ่ม Chrome options สำหรับโหมด headless และความเสถียร แล้วจำกัดสิ่งที่ Selenium Wire จับไว้เพื่อไม่ให้ request buffer โตไม่สิ้นสุด บน server การทำ headless ร่วมกับการจำกัดขอบเขตการจับคือความต่างระหว่างงานที่รันได้หลายชั่วโมงกับงานที่ใช้ RAM จนหมด

เริ่มด้วยชุด Chrome flags ที่เหมาะสมสำหรับ container แบบ headless หรือสภาพแวดล้อม CI:

from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--headless=new")     # modern headless mode
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--window-size=1920,1080")

proxy_url = "http://login:[email protected]:823"
seleniumwire_options = {
    "proxy": {"http": proxy_url, "https": proxy_url,
              "no_proxy": "localhost,127.0.0.1"}
}

driver = webdriver.Chrome(options=chrome_options,
                          seleniumwire_options=seleniumwire_options)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

โดยค่าเริ่มต้น Selenium Wire จับและ buffer request กับ response ทุกตัว ซึ่งกินหน่วยความจำในการรันยาว ๆ อย่างแท้จริง จำกัดการจับด้วย driver.scopes เก็บ storage ในหน่วยความจำ และล้าง buffer ระหว่างหน้า:

from seleniumwire import webdriver

seleniumwire_options = {
    "proxy": {"http": proxy_url, "https": proxy_url,
              "no_proxy": "localhost,127.0.0.1"},
    "request_storage": "memory",   # keep the buffer in RAM, not on disk
}

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)

# Only capture the API traffic you care about. Images, fonts, analytics, and
# tracking pixels are ignored, which keeps the capture buffer small.
driver.scopes = [r".*/api/.*"]

driver.get("https://example.com/products")
for request in driver.requests:
    print(request.url)

del driver.requests   # clear the buffer between pages on long-running jobs
driver.quit()

รายการ scopes คือชุด URL regex; สิ่งที่อยู่นอกขอบเขตจะผ่านไปแต่ไม่ถูกเก็บ สำหรับ scraper ที่ต้องการเฉพาะ API responses วิธีนี้ลด resident buffer ได้มาก การลดสิ่งที่ดาวน์โหลดยังลดต้นทุน proxy เพราะ traffic ของ DataImpulse คิดค่าบริการต่อ gigabyte

Selenium Wire จัดการ HTTPS และ certificate อย่างไร?

เพื่ออ่านเนื้อหา request และ response ที่เข้ารหัส Selenium Wire ถอดรหัส HTTPS แบบ man-in-the-middle โดยใช้ root certificate ของตนเอง ซึ่งจะ inject เข้า browser profile โดยอัตโนมัติสำหรับ Chrome และ Firefox วิธีนี้ทรงพลังแต่มีข้อจำกัดตามจริงที่ควรเข้าใจก่อนพึ่งพา

from seleniumwire import webdriver

proxy_url = "http://login:[email protected]:823"
seleniumwire_options = {
    "proxy": {"http": proxy_url, "https": proxy_url,
              "no_proxy": "localhost,127.0.0.1"},
    # Selenium Wire is a man-in-the-middle proxy: to read HTTPS bodies it
    # decrypts traffic using its own root certificate, which it injects into
    # the browser profile automatically. These two options relax verification
    # on the upstream leg so a mismatched or self-signed cert does not abort.
    "verify_ssl": False,
    "suppress_connection_errors": True,
}

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)
driver.get("https://example.com")
driver.quit()

มี 2 ประเด็นตามมาจากการออกแบบแบบ man-in-the-middle ประการแรก site ที่ใช้ certificate pinning จะปฏิเสธ certificate ที่ inject และการดัก traffic นั้นจะล้มเหลว; ในกรณีนั้นให้ปิด capture สำหรับ host ที่ได้รับผลกระทบ หรือกลับไปไม่ตรวจเนื้อหา ประการที่สอง หากเปิด Chrome ด้วย profile ที่กำหนดเองหรือไม่ใช่ค่าเริ่มต้น อาจต้องตรวจให้แน่ใจว่า Selenium Wire CA ได้รับความเชื่อถือในนั้น options verify_ssl และ suppress_connection_errors จะผ่อนการตรวจสอบฝั่ง upstream เพื่อให้ certificate ที่ไม่ตรงหรือ self-signed ไม่ยกเลิกการรัน แต่ไม่สามารถเอาชนะ pinning ได้

ใช้ร่วมกับ undetected-chromedriver ได้หรือไม่ และมีทางเลือกอะไรบ้าง?

ได้ Selenium Wire มาพร้อม integration ของ undetected-chromedriver ที่ import เป็น seleniumwire.undetected_chromedriver ทำให้ได้การตรวจสอบ request และ proxy ที่ยืนยันตัวตน ขณะที่ undetected-chromedriver ลด automation fingerprints นี่คือชุดผสมที่นิยมสำหรับเป้าหมายที่มีการป้องกัน

# Selenium Wire ships its own undetected-chromedriver integration.
import seleniumwire.undetected_chromedriver as uc

proxy_url = "http://login:[email protected]:823"
seleniumwire_options = {
    "proxy": {"http": proxy_url, "https": proxy_url,
              "no_proxy": "localhost,127.0.0.1"}
}

options = uc.ChromeOptions()
options.add_argument("--headless=new")

driver = uc.Chrome(seleniumwire_options=seleniumwire_options, options=options)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

เมื่อ Selenium Wire เองไม่เหมาะ มี 2 ทางเลือกที่ครอบคลุมความต้องการส่วนใหญ่ Plain Selenium 4 ใช้ proxy ที่ยืนยันตัวตนผ่าน extension ขนาดเล็กที่สร้างขึ้นได้ ซึ่ง helper library ทำให้อัตโนมัติ:

from selenium import webdriver
# Plain Selenium cannot send proxy credentials on its own. A small helper builds
# a throwaway Chrome extension that answers the proxy auth challenge for you.
from selenium_authenticated_proxy import SeleniumAuthenticatedProxy

proxy = SeleniumAuthenticatedProxy(
    proxy_url="http://login:[email protected]:823"
)
options = webdriver.ChromeOptions()
proxy.enrich_options(options)

driver = webdriver.Chrome(options=options)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

Playwright จัดการ proxy ที่ยืนยันตัวตนได้โดย native และยังมีการดูแลเชิงรุก จึงเป็นรากฐานที่ดีกว่าสำหรับโครงการใหม่:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        headless=True,
        proxy={
            "server": "http://gw.dataimpulse.com:823",
            "username": "login",
            "password": "password",
        },
    )
    page = browser.new_page()
    page.goto("https://api.ipify.org")
    print(page.inner_text("body"))
    browser.close()

นี่คือการเปรียบเทียบทั้ง 3 โดยเฉพาะสำหรับงาน proxy ที่ยืนยันตัวตน:

เครื่องมือ proxy ที่ยืนยันตัวตน การตรวจสอบ request การดูแลรักษา เหมาะสำหรับ
Plain Selenium 4 ต้องใช้ helper สำหรับ auth extension ไม่ ยังดูแลอยู่ flow ง่าย ๆ ที่ไม่ต้องจับ request
Selenium Wire มีในตัว option เดียว เข้าถึง request และ response ได้ครบ เก็บถาวรแล้ว ให้ตรึงเวอร์ชัน debugging และควบคุม header บน Selenium code เดิม
Playwright มีในตัวแบบ native ดัก route และ response ยังดูแลอยู่ โครงการใหม่ที่ต้องการ tooling สมัยใหม่

คำแนะนำในการย้าย: หากต้องการเพียง proxy ที่ใช้ credentials และไม่ต้องจับ request, Selenium ปกติพร้อม auth extension เป็นทางเลือกที่เบาที่สุดและยังอยู่บน code ที่มีการดูแล หากต้องตรวจสอบหรือเขียน traffic ใหม่และกำลังเริ่มต้นใหม่ Playwright ให้สิ่งนี้แบบ native โดยไม่มีภาระการตรึงเวอร์ชัน ให้ใช้ Selenium Wire ต่อเมื่อมี Selenium codebase เดิมซึ่งการสร้างการควบคุมระดับ request ใหม่มีต้นทุนสูง สำหรับการเลือก IP กับเครื่องมือใดก็ตาม ให้เปรียบเทียบ residential proxies, datacenter proxies และ mobile proxies กับการป้องกันของเป้าหมาย

การจัดการ proxy ที่ยืนยันตัวตนตามเครื่องมือ

คำถามที่พบบ่อย

ตั้งค่า proxy ที่ยืนยันตัวตนใน Selenium Wire อย่างไร?

ส่ง proxy dict ที่มี URL ของ http และ https ในรูป login:password@host:port ภายใน seleniumwire_options ตอนสร้าง driver และเพิ่ม no_proxy สำหรับ localhost ไม่ต้องใช้ extension หรือวิธีแก้ปัญหา auth dialog

เหตุใด Selenium Wire จึงล้มเหลวด้วย blinker ImportError?

blinker 1.8 ลบชื่อภายในที่ Selenium Wire import ตอนเริ่มต้น ให้ตรึง blinker ต่ำกว่า 1.8 เช่น blinker==1.7.0 พร้อมเวอร์ชัน selenium-wire และ selenium ที่ตรึงไว้

Selenium Wire ยังมีการดูแลอยู่หรือไม่?

โครงการต้นฉบับถูกเก็บถาวรและไม่มีการดูแลเชิงรุกแล้ว ยังทำงานได้ด้วยเวอร์ชันที่ตรึงไว้ แต่ให้ทดสอบการอัปเกรด Selenium หรือ Chrome แต่ละครั้งแยกต่างหาก และพิจารณา fork ที่ยังดูแลหรือ Playwright สำหรับโครงการใหม่

จะตรวจว่า proxy ถูกใช้งานจริงได้อย่างไร?

โหลดบริการสะท้อน IP เช่น api.ipify.org ใน driver แล้วตรวจว่าที่อยู่ที่ตอบกลับคือ proxy ไม่ใช่ของคุณเอง คุณยังอ่าน driver.requests เพื่อดูว่า traffic ผ่าน gateway ได้

Selenium Wire อ่าน traffic ของ HTTPS ได้หรือไม่?

ได้ โดยทำงานเป็น man-in-the-middle proxy และ inject root certificate ของตนเองเพื่อถอดรหัสเนื้อหา HTTPS site ที่ใช้ certificate pinning จะปฏิเสธ จึงให้ปิด capture สำหรับ host เหล่านั้น

DataImpulse ไม่เหมาะเมื่อใด?

หากต้องการ static ISP proxies, scraping API ที่มีการจัดการครบ หรือการเข้าถึง site ธนาคารและภาครัฐ DataImpulse ไม่ใช่เครื่องมือที่เหมาะ โดยมุ่งเน้น residential, mobile และ datacenter proxies แบบหมุนเวียนสำหรับเก็บข้อมูลสาธารณะและเข้าถึงเนื้อหา

รัน Selenium Wire ผ่าน proxy ที่เชื่อถือได้

proxy ของ Selenium Wire จะดีได้เท่ากับ IP ที่อยู่เบื้องหลัง คุณสามารถส่ง browser automation ผ่าน residential, mobile หรือ datacenter IP ที่จัดหาตามหลักจริยธรรม ด้วย traffic แบบจ่ายตามการใช้งานเริ่มต้น 1 ดอลลาร์ต่อ GB สร้างบัญชี DataImpulse แล้วเริ่มใช้ session แบบหมุนเวียนหรือ sticky session