Abdur-Rahmaan Janhangeer writes:
> results = []
> with console.status("Checking internet ...", spinner="dots"):
> for domain in domains:
> try:
> requests.get(domain)
> results.append(1)
> except Exception as e:
> results.append(0)
> if not any(results):
> print('No internet connection')
> sys.exit()
> 
> gist link:
> https://gist.github.com/Abdur-rahmaanJ/7917dc5ab7f5d2aa37b2723909be08f7
> 
> I think for me having the internet means ability to request urls

Request urls and get the right answer?

This won't work if you're behind a captive portal: every URL you
try to get will return successfully, but the content will be
the captive portal page.

You need to compare the output of at least one of those pages to
known output to be sure you're really connected.

        ...Akkana
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to