我现在在几个程序上都遇到了这个错误。我尝试升级 pytube、重新安装它、尝试一些修复、更改 URL 和代码,但似乎没有任何效果。
from pytube import YouTube
#ask for the link from user
link = input("Enter the link of YouTube video you want to download: ")
yt = YouTube(link)
#Showing details
print("Title: ",yt.title)
print("Number of views: ",yt.views)
print("Length of video: ",yt.length)
print("Rating of video: ",yt.rating)
#Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()
#Starting download
print("Downloading...")
ys.download()
print("Download completed!!")
Run Code Online (Sandbox Code Playgroud)
这是错误代码:
from pytube import YouTube
#ask for the link from user
link = input("Enter the link of YouTube video you …Run Code Online (Sandbox Code Playgroud) 我有一段这样的代码
host = 'http://www.bing.com/search?q=%s&go=&qs=n&sk=&sc=8-13&first=%s' % (query, page)
req = urllib2.Request(host)
req.add_header('User-Agent', User_Agent)
response = urllib2.urlopen(req)
Run Code Online (Sandbox Code Playgroud)
当我输入一个大于一个单词的查询,如"狗"时,我得到以下错误.
response = urllib2.urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) …Run Code Online (Sandbox Code Playgroud) 设置:Windows 7,IIS7.我正在开发一个通过本地IIS服务器查看的应用程序,而不是内置的调试Web服务器.所以我的应用网址是http://localhost/foo/bar.aspx.有没有 <customErrors>在我的web.config部分,我还没有在IIS中更改的设置.
如果发生任何错误,我总是会出现以下错误屏幕:
HTTP错误500.19 - 内部服务器错误 web.config文件中的部分不允许使用
绝对物理路径"C:\inetpub\custerr"system.webServer/httpErrors.请改用相对路径.
这是我的applicationhost.config内容:
<httpErrors errorMode="Custom" lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
<error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="401.htm" />
<error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="403.htm" />
<error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="404.htm" />
<error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="405.htm" />
<error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="406.htm" />
<error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="412.htm" />
<error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="500.htm" />
<error statusCode="501" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="501.htm" />
<error statusCode="502" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="502.htm" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
如何摆脱此配置错误,以便查看详细错误?
我在Windows 7中运行IIS 7.5并且已经进入"打开或关闭Windows功能"并在"Internet信息服务/万维网服务/应用程序开发功能"中启用了ASP.一旦我这样做,我开始收到HTTP 404错误说:
由于扩展
配置,无法提供您请求的页面.如果页面是脚本,请添加处理程序.如果要
下载文件,请添加MIME映射.
所以我认为我需要在Handler映射中添加映射到*.asp,并且处理程序映射到C:\ Windows\System32\inetsrv\asp.dll.但是当我尝试加载页面时,我收到服务器错误说:
无法加载类型'C:\ Windows\system32\inetsrv\asp.dll'.
有谁知道这里发生了什么或如何处理这个?
我应该提到的另一件事是我已经在我的应用程序池中启用了32位应用程序并将ASP设置为向浏览器发送错误,但这些都没有解决问题或给我更多信息.
请注意这是ASP Classic而不是ASP.NET,ASP.NET对我来说工作得很好.
在IIS中,我可以配置自定义错误页面.
对于每个HTTP错误代码,我可以说去哪里.有几个代码有许多"子"代码可用.例如,404具有常规404,404; 1,404; 2等等.
它们适用于什么?他们什么时候回来的?我应该为这些错误制作自定义页面吗?我可以以某种方式轻松配置所有代码"家庭"来到同一页面?
我正在将数据发送到带有Arduino的服务器,这需要逐行构建HTML POST.我不一定知道Content-Length a-priori,所以我使用"chunked"编码.
当我尝试使用rfc2616中指定的"Transfer-Encoding"选项从Wikipedia发布此示例帖子时
client.println("POST /myurl HTTP/1.1");
client.println("Host: 12.345.679.999"); // replaced with the test server's IP
client.println("User-Agent: Arduino/1.0");
client.println("Transfer-Encoding: chunked");
client.println();
client.println("4");
client.println("test");
client.println("0");
client.println();
Run Code Online (Sandbox Code Playgroud)
或者,使用转义字符显式:
client.print("4\r\ntest\r\n0\r\n\r\n");
Run Code Online (Sandbox Code Playgroud)
我从服务器收到错误:
HTTP/1.1 411 Length Required
A request of the requested method POST requires a valid Content-length.
Server: Apache/2.2.22 (Ubuntu)
Run Code Online (Sandbox Code Playgroud)
但是,"chunked"编码不应该要求Content-Length头字段,请参阅rfc2616中的4.4 - 消息长度
我错过了一个领域吗?为什么这个电话不起作用?
为了记录,非Chunked-Encoding工作:
if(client.connect(server, 80)){
String PostData = "test";
Serial.println("POST /myurl HTTP/1.1");
client.println("Host: 12.345.679.999"); // replaced with the test server's IP
Serial.println("User-Agent: Arduino/1.0"); …Run Code Online (Sandbox Code Playgroud) 如果我使用这样的约束 @NotNull 然后在控制器中
public User createUser(
@Validated
@RequestBody User user) {}
Run Code Online (Sandbox Code Playgroud)
它提供了一个非常好的 400 异常细节。
但是,如果我像这样使用自己的自定义验证器:
public User createUser(
@UserConstraint
@RequestBody User user) {}
Run Code Online (Sandbox Code Playgroud)
它会抛出一个 500 服务器错误,如下所示:
javax.validation.ConstraintViolationException: createUser.user: Error with field: 'test35'
at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:117) ~[spring-context-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69) ~[spring-security-core-5.1.6.RELEASE.jar:5.1.6.RELEASE]
Run Code Online (Sandbox Code Playgroud)
有没有办法让 400 消息得到响应?
理想情况下,400 消息应该与 Spring 的验证 JSON 相同
{
"timestamp": "2019-10-30T02:33:15.489+0000",
"status": 400,
"error": "Bad Request",
"errors": [
{
"codes": [
"Size.user.lastName",
"Size.lastName",
"Size.java.lang.String",
"Size"
],
"arguments": [
{
"codes": [
"user.lastName",
"lastName"
],
"arguments": null,
"defaultMessage": "lastName", …Run Code Online (Sandbox Code Playgroud) 我刚开始使用Python中的goslate库来检测文本中单词的语言,但在测试了7-8个输入之后,我给出了输入,其中包含用阿拉伯语和英语两种语言编写的单词.之后,它开始给我错误.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
execfile("C:/test_goslate.py");
File "C:/test_goslate.py", line 12, in <module>
language_id = gs.detect('الدولة')
File "C:\Python27\lib\site-packages\goslate.py", line 484, in detect
return self._detect_language(text)
File "C:\Python27\lib\site-packages\goslate.py", line 448, in _detect_language
return self._basic_translate(text[:50].encode('utf-8'), 'en', 'auto')[1]
File "C:\Python27\lib\site-packages\goslate.py", line 251, in _basic_translate
response_content = self._open_url(url)
File "C:\Python27\lib\site-packages\goslate.py", line 181, in _open_url
response = self._opener.open(request, timeout=self._TIMEOUT)
File "C:\Python27\lib\urllib2.py", line 410, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 523, in http_response
'http', request, response, code, msg, …Run Code Online (Sandbox Code Playgroud) 我的应用程序在很大程度上依赖于android DownloadManager组件来下载大小为3-10兆字节的文件.
在扩大规模(达到数百万次下载)时,整体情况很明显:
由于ERROR_HTTP_DATA_ERROR ,所有下载中约有50%失败.
我从谷歌分析中获取此信息
根据文档,此错误代码代表:
在HTTP级别发生错误接收或处理数据时COLUMN_REASON的值.
我发现这个文档不是很有用.
那里有很多http错误.
以及下载过程中的网络断开情况怎么样?它是否也在ERROR_HTTP_DATA_ERROR失败所有下载的管理器重试尝试后触发错误?
如果有人能帮我理解,那就太好了:
DownloadManager更多关于确切的http错误的信息?ERROR_HTTP_DATA_ERROR下载管理器可以解决哪些最常见的情况?另一点值得一提:虽然这个错误累积 - 用户连接到WIFI网络(我设置下载管理器只能通过wifi下载)
请不要建议我根本不使用下载管理器.我知道这个选项,优点和缺点.我将此选项保存为最后的手段.
我正在设计一个RESTful API,它使用HTTP状态代码和动词作为通信的关键组件.
在宗教层面上,它是在RESTafarian的狂热者一面.
决定HTTP状态代码的经验法则是此图或类似资源.
GET /api/documents/1- 401用户尚未登录GET /api/documents/1- 200用户有权限GET /api/documents/1- 403用户没有权限DELETE /api/documents/1- 204用户有权限DELETE /api/documents/1- 403用户没有权限GET /api/documents/2- 404用户权限无关,资源不存在DELETE /api/documents/2- 404用户权限无关,资源不存在DELETE /api/documents/1- 404用户拥有权限,资源已被删除DELETE /api/documents/1- 404用户没有权限,资源已被删除目标:
在这种情况下,有很多不同的状态代码可供选择(404,403,410,405),在我的情况下,我在现有资源上使用403,如果它不是你的不清除缓存,而404是非所有非现有资源,以告诉客户擦除该数据.
但我不喜欢在不属于你的资源上从403切换到404.
我很想听听其他人如何解决这个用例,或者一般情况下你认为适合发送所有无效DELETE调用的状态代码,因为我认为这是最难以简洁的一个.
(整个互联网上的很多REST讨论和答案都只是"扔了400个糟糕的请求,无论如何都不关心",我没有需要快速修复或务实破解的问题.谢谢)
http-error ×10
http ×3
python ×3
android ×1
api ×1
arduino ×1
asp-classic ×1
exception ×1
goslate ×1
http-headers ×1
http-post ×1
iis ×1
iis-7 ×1
iis-7.5 ×1
permissions ×1
pytube ×1
rest ×1
spring-boot ×1
urllib2 ×1
validation ×1