简体   繁体   中英

“JavaScript is not available” (Python, Selenium, Chromedriver and Ubuntu)

I am trying to scrape some data from a webpage (Twitter). When I run my program on my computer (Windows 10), it works fine. But when I try to run it on a Linux server, the html that I get from the webpage says:

<h1>JavaScript is not available.</h1> 
<p>We've detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center.</p>

My code is the following:

browser_path = '/usr/bin/chromedriver'
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--enable-javascript")
browser = webdriver.Chrome(executable_path = browser_path, options=chrome_options)

Can anyone help me to find the problem and fix it please? Thank you very much in advance

I don't think chrome supports chromedriver anymore, try scraping on FireFox with using FireFox's geckodriver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM