I'm creating a login automation code for the site I signed up for Python Selenium, how do I check if I have an Internet connection?

Asked 2 years ago, Updated 2 years ago, 42 views

Creating a login automation code for the site you subscribed to Python Selenium.

By the way, if you try to log in while the Internet is not connected, an error will occur.

In this case, check the current network status before attempting to log in and only if the Internet is connected

I'd like to have them try to log in.

The login automation code itself is easy, checking if the Internet is currently connected.

How do I write the code?

python selenium

2022-09-22 18:11

1 Answers

The internet...There's a lot of information in one word.

When asked if you want to limit only the application layer, which is the highest layer in http, or osi 7 layer, to the Internet, it should be clear whether "network status" or network monitoring is required.

It's simple to check if there's no problem with the http connection. You can connect to a always-serving place like Google with a module like requests and get the results back.

But think about it carefully. The http service may be networking fine, but it may not be possible due to dns problems. In this case, you can try connecting to port 53 of the famous dns with a socket and receive it as false with an error message in case of an exception.


2022-09-22 18:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.