0

When trying to open a certain URL where a jacket is shown with selenium-python the page automatically redirects me to the European home-screen

Here's my code (USA store):

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

Website redirects me once I open that URL to this one (European store)

https://shop.palaceskateboards.com/

Is there any way to stop it from redirecting me?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Possible duplicate of [selenium with scrapy for dynamic page](https://stackoverflow.com/questions/17975471/selenium-with-scrapy-for-dynamic-page) – Felipe Valdes Jan 01 '19 at 03:49

1 Answers1

0

Disable 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)
Bitto
  • 7,937
  • 1
  • 16
  • 38
  • @Redfactor Give the path to chromdriver in executable_path='/path/to/chromedriver' – Bitto Dec 31 '18 at 20:20
  • File "C:\python37\lib\subprocess.py", line 775, in __init__ restore_signals, start_new_session) File "C:\python37\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified – Redfactor Dec 31 '18 at 20:21
  • @Redfactor On windows executable_path='/path/to/chromedriver.exe' - '.exe' is required – Bitto Dec 31 '18 at 20:22
  • Ok sorry im new to this so where do i go then to add the executable you added – Redfactor Dec 31 '18 at 20:26
  • @Redfactor First find the path to the chromedriver.exe that you downloaded. The add it in this line browser = webdriver.Chrome(executable_path='/path/to/chromedriver',chrome_options=chrome_options) instead of /path/to/chromedriver – Bitto Dec 31 '18 at 20:28
  • C:\Users\sally\Downloads\chromedriver_win32(1).exe . If possible rename it to chromedriver and use C:\Users\sally\Downloads\chromedriver.exe – Bitto Dec 31 '18 at 20:32
  • browser = webdriver.Chrome(executable_path='C:/Users/sally/Downloads/chromedriver_win32(1)',chrome_options=chrome_options) is this ok? – Redfactor Dec 31 '18 at 20:33
  • @Redfactor webdriver.Chrome(executable_path='C:/Users/sally/Downloads/chromedriver_win32(1).exe',chrome_options=chrome_options) – Bitto Dec 31 '18 at 20:35
  • PermissionError: [WinError 5] Access is denied gave me erro – Redfactor Dec 31 '18 at 20:38
  • @Redfactor I can't help you more than this. Copy it to the same folder as your python file and use webdriver.Chrome(executable_path='chromedriver_win32(1).exe',chrome_options=chrome_options) – Bitto Dec 31 '18 at 20:41
  • rip copied it to the same file as my python folder dosn`t work – Redfactor Dec 31 '18 at 21:12
  • @Redfactor I can't see your system. So i may not be able to solve this for you. You need to find the path to an executable file (.exe) (chromedriver) and add it to your executable_path. https://stackoverflow.com/questions/17436598/getting-chrome-to-launch-via-selenium – Bitto Dec 31 '18 at 21:16