kaggle内核:urllib.request.urlopen不适合任何URL

假设XYZ

处理url中的列表的最佳方法是什么kaggle kernels

我尝试使用进行首次测试google.com

First Method:使用urllib.request

import urllib.request resp =  urllib.request.urlopen('http://www.google.com')

这会导致gai错误和urlopen错误[Errno -2]名称或服务未知

Second Method:使用请求

import requests resp = requests.get('http://www.google.com')

这导致错误gaierror:[Errno -3]名称解析暂时失败,并且无法建立新连接:[Errno -3]名称解析暂时失败。

import urllib.request
req = urllib.request.Request('http://www.google.com')
print (req)

try:
    response = urllib.request.urlopen(req)
    print (response)
except urllib.error.URLError as e:
    print (e.reason)
    print("something wrong")

输出:

<urllib.request.Request object at 0x7fed1d00c518>
[Errno -2] Name or service not known
something wrong

我尝试按照stackoverflow answer的建议解析DNS解析

解决该错误的方法是什么?为什么urlopen或请求在kaggle内核中不起作用?
我已经看到许多具有相同错误的内核:内核1 内核2 内核3

雷切尔·塔特曼(Rachael Tatman)

这对您不起作用的原因是因为Kaggle Kernels当前无法访问互联网。结果,您无法进行需要内核中的网络连接的API调用。

编辑2018年8月:仅供参考,我们现在已向内核添加了互联网访问权限。:)您可以在编辑器的左侧栏中启用它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

urllib.request.urlopen 不适用于特定网站

带有验证的urllib.request.urlopen(url)

替换urllib.request.urlopen(url,ca *)的开启器

Linux内核模块/ IOCTL:不适合设备的ioctl

如何使用 urllib.request.urlopen 从多个 url 获取所有图像 url

urllib.request.urlopen(url) 在 python 3 中不起作用

Python 3.6.2 url.request.urlopen() urllib.error.HTTPError:HTTP 错误 403:禁止

urllib.request.urlopen(url)如何通过IP地址使用此功能?

HTTP错误401:未经授权使用urllib.request.urlopen

HTTPError问题:urllib.request.urlopen python请求错误

将 urllib.request.urlopen 移动到请求

python:urllib.request.urlopen不起作用

如何处理来自urllib.request.urlopen()的响应编码

模拟urllib.request.urlopen的read函数返回MagicMock签名

Python 3:urllib.request.urlopen和Progressbar

urllib.request 的 urlopen 无法在 python 3.7 中打开页面

urllib,urllib2,urllib.request.open,AttributeError:“模块”对象没有属性“ urlopen”

Python文档:urllib.request.urlopen(URL,data = None,[timeout,] *,cafile = None中的方括号是什么意思?

CSS 不适合

如何放置任何类都不适合的方法

如何使用urllib.request获取文件的URL列表?

python 3.7 urllib.request不跟随重定向URL

urllib2.Request检查URL是否可访问

Python urllib.request.urlopen:AttributeError:“ bytes”对象没有属性“ data”

Python请求lib工作,urllib.request.urlopen POST不工作

urllib.request.urlopen返回字节,但是我无法对其进行解码

urllib.request.urlopen无法获取堆栈溢出选举的主要页面

我需要使用urllib2.Request / urlopen处理哪些错误/异常?

为什么在这种情况下urllib.request.urlopen会阻塞?