【问题标题】:Opening USA Clothing website with selenium python redirects me to the Europe Clothing Website home-screen使用 selenium python 打开 USA Clothing 网站会将我重定向到 Europe Clothing 网站的主屏幕
【发布时间】:2019-05-28 04:28:02
【问题描述】:

当尝试打开某个 URL 时,使用 selenium-python 显示夹克时,页面会自动将我重定向到欧洲主屏幕

这是我的代码(美国商店):

URL = 'https://shop-usa.palaceskateboards.com/products/reversible-spherie-jacket-gold-petrol'
browser = webdriver.Chrome()
browser.get(URL)
webbrowser.open(URL)

一旦我打开该 URL 到这个(欧洲商店),网站就会将我重定向

https://shop.palaceskateboards.com/

有什么办法可以阻止它重定向我?

【问题讨论】:

标签: python url redirect selenium-webdriver https


【解决方案1】:

禁用javascript

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option( "prefs",{'profile.managed_default_content_settings.javascript': 2})
browser = webdriver.Chrome(executable_path='/path/to/chromedriver',chrome_options=chrome_options)
url='https://shop-usa.palaceskateboards.com/products/reversible-spherie-jacket-gold-petrol'
browser.get(url)

【讨论】:

  • @Redfactor 在 executable_path='/path/to/chromedriver' 中给出 chromdriver 的路径
  • 文件“C:\python37\lib\subprocess.py”,第 775 行,在 init restore_signals, start_new_session) 文件“C:\python37\lib\subprocess.py ", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件
  • @Redfactor On windows executable_path='/path/to/chromedriver.exe' - '.exe' 是必需的
  • 好吧,对不起,我是新手,所以我该去哪里添加你添加的可执行文件
  • @Redfactor 首先找到你下载的chromedriver.exe的路径。在这一行添加它 browser = webdriver.Chrome(executable_path='/path/to/chromedriver',chrome_options=chrome_options) 而不是 /path/to/chromedriver
猜你喜欢
  • 2020-08-18
  • 2013-07-09
  • 2018-08-13
  • 2019-07-31
  • 2015-10-19
  • 1970-01-01
  • 2017-02-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多