Is there a way to detect if a web client is a puppeteer instance? [duplicate]

大憨熊 提交于 2020-06-27 14:37:11

问题


I want to detect if a client visiting a website is using puppeteer instead of being a real user.

Does puppeteer add a request header that tells that the request is coming from puppeteer?

Edit:

Imagine I created a website. I want to block users using puppeteer because I want my users to be "real" users (person that clicks a button, not a script imitating a button click). I want to know if there is anything specific I could check (headers?) that would identify him as being puppeteer and not a real human so I could ignore his requests (i.e. not save anything in database, redirect to error page or other things)

Another Edit:

As @root pointed out, I could detect in browser if a user agent is controlled by automation (like Puppeteer). Although this is not what was on my mind first (I want to detect headers so I would ignore/block processing in server side and be able to log then to pinpoint users who use automation), I would accept it as the answer if no other alternative is present.


回答1:


If you mean "a client visiting MY website" and "using a webdriver instead of being a real user", you can add a JavaScript snippet to your site that checks navigator.webdriver and if it's true, then the site behaves differently.



来源:https://stackoverflow.com/questions/55998010/is-there-a-way-to-detect-if-a-web-client-is-a-puppeteer-instance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!