from socket import timeout
try:
response = urllib.request.urlopen(url, timeout=10).read().decode('utf-8')
except (HTTPError, URLError) as error:
logging.error('Data of %s not retrieved because %s\nURL: %s', name, error, url)
except timeout:
logging.error('socket timed out - URL %s', url)
else:
logging.info('Access successful.')
相关文章
- 01-30python – pandas srt.lower()不处理dataframe列
- 01-30用来处理gwdac网站爬取的实验数据的python代码
- 01-30python中字符串(str)的常用处理方法
- 01-30Python3 pip命令报错:Fatal error in launcher: Unable to create process using '"'
- 01-30python+openCV图像处理(二十三)轮廓检测
- 01-30[Python图像处理]十二.图像向下取样和向上取样
- 01-30python+openCV图像处理(四)色彩空间转换
- 01-30Python 中的时间处理包datetime和arrow
- 01-30python中文处理之encode/decode函数
- 01-30python密码处理(可用于生产模式)