简体   繁体   中英

PhantomJS screen capture: unsupported browser message

I'm using PhantomJs and sometimes when i take a screenshot of a browser I get recorded an "unsupported browser" message on the recorded screenshot...

which agent should I use? why doe it happen?

my template has this line

page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36';

page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36';

Chrome 37 is a pretty old browser. Using the useragent for Chrome from the recent year works fine most of the time.

Another reason for such a warning (although it is less likely) could be PhantomJS lacking some recent browser features, like ES6 (although v2.5 beta 2 for Windows is rather decent in this aspect, being relatively unstable overall) .

If you are not too invested in PhantomJS at the time I'd suggest you try puppeteer which is very close in syntax to it but has the newest dev Chromium underneath.

You may want to randomly switch agents to prevent the scraping preventing program made by some websites.

You could also load the web driver from the local machine to prevent this.

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