0

I'm attempting to do some web scraping using headless chrome via selinium-webdriver on Heroku but most recently ran into trouble. Visiting, https://music.youtube.com I get a page with the following:

<div class="message">
  Sorry, YouTube Music is not optimized for your browser. Check for updates or try Google Chrome.
</div>

I can confirm that my chrome driver is up to date and nothing on my end has changed to cause this break in functionality. Using any other automated scraping gem similar to selinium gives me a similar message in telling me my browser is deprecated. Note that performing these actions is no problem when I do it on my local machine. To give some background, I originally followed this answer to get everything running correctly on heroku prior to the breakage. On top of this here's my setup:

gem 'selenium-webdriver'
gem 'webdrivers', '~> 4.0', require: false

require 'webdrivers'
require 'selenium-webdriver'

chrome_bin_path = ENV.fetch('GOOGLE_CHROME_SHIM', nil)

options = Selenium::WebDriver::Chrome::Options.new
options.binary = chrome_bin_path if chrome_bin_path
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')

$driver = Selenium::WebDriver.for :chrome, options: options

What would be the most logical answer to why I'm getting this message on a site like youtube?

Carl Edwards
  • 13,826
  • 11
  • 57
  • 119
  • You might want to check your user agent and try changing it to something else. The user agent header is the way websites try and figure out what browser you're on – max pleaner Oct 10 '20 at 17:37
  • Good idea. Tried with:`options.add_argument("--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36")`. Strangely I get a timeout error. – Carl Edwards Oct 10 '20 at 19:02

0 Answers0