Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
66 views
in Technique[技术] by (71.8m points)

javascript - Puppeeter - Catch no connection Error and do some action

I would like to use a puppeeter to create a bot that will check if there is an active internet connection (sometimes it breaks it and I have to reset the router), so if the connection failed, the bot would automatically log into my router panel and reset it (this is not is a problem, but I do not know how to catch the lack of internet with a puppeter)

Thank you very much for any help and idea!

#update

guys, i know how to use puppetter, and implement this thing, BUT i dont know what should i put into condition, to check connection, for example i have

some loop lets say

 for (let i = 0; i < 20000; i++) {
if(NOCONNECTION){then do something}
 await delay(randomInteger(18000, 48000));
}

I just dont know, how to check if i have connection ;/ - so the problem is NOCONNECTION ;/

question from:https://stackoverflow.com/questions/65917840/puppeeter-catch-no-connection-error-and-do-some-action

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Maybe you can listen for 'offline' event or check navigator.onLine in an interval.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...