I have a large text file of URLs which I have to download via wget. I have written a small python script which basically loops through each domain name and download them using wget (os.system("wget "+URL)). But the problem is that wget just hangs on a connection if the remote server doesn't reply after connecting. How do I set a time limit in such a case? I want to terminate wget after some time if the remote server is not replying after connection.
Regards,
Use the --timeout seconds argument to limit the time for a request. You can be more specific and use --connect-timeout seconds if needed. See the wget Manual for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With