godall
V2EX  ›  问与答

有个牛逼的网站(上海房地产),无法用 Python 打开网页访问

  •  
  •   godall · Nov 11, 2024 · 853 views
    This topic created in 547 days ago, the information mentioned may be changed or developed.
    网站地址: https://183.194.252.232:2004/old_house/old_house.html
    正常用浏览器访问正常,摁下 F12 调试模式也可以,虽然有断点防跟踪,但是直接禁用断点就可以了。
    但是用 python selenium 就是不行,访问该地址直接空白,返回 400 错误,不知道怎么做到的

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

    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches",['enable-automation'])
    options.binary_location=r'D:\programs\chrome\chrome.exe'
    options.add_argument('--no-sandbox')
    options.add_argument('--enable-chrome-browser-cloud-management')
    driver = webdriver.Chrome(options=options)

    url='https://183.194.252.232:2004/old_house/old_house.html'
    try:
    driver.get(url)
    driver.implicitly_wait(5)
    time.sleep(15)
    except Exception as e:
    import traceback
    logger.error( traceback.format_exc() )
    finally:
    driver.quit()
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3802 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:05 · PVG 13:05 · LAX 22:05 · JFK 01:05
    ♥ Do have faith in what you're doing.