我正在浏览http://ruby.bastardsbook.com/上提供的Ruby教程,我遇到了以下代码:
require "open-uri"
remote_base_url = "http://en.wikipedia.org/wiki"
r1 = "Steve_Wozniak"
r2 = "Steve_Jobs"
f1 = "my_copy_of-" + r1 + ".html"
f2 = "my_copy_of-" + r2 + ".html"
# read the first url
remote_full_url = remote_base_url + "/" + r1
rpage = open(remote_full_url).read
# write the first file to disk
file = open(f1, "w")
file.write(rpage)
file.close
# read the first url
remote_full_url = remote_base_url + "/" + r2
rpage = open(remote_full_url).read
# write the second file to disk
file = …Run Code Online (Sandbox Code Playgroud) 我一直在阅读类似问题的几十个例子,但我无法得到我见过的任何解决方案或它们的变体.我是屏幕抓取,我只想忽略404错误(跳过页面).我明白了
'AttributeError:'module'对象没有属性'HTTPError'.
我也试过'URLError'.我已经看到接近完全相同的语法作为工作答案.有任何想法吗?这是我得到的:
import urllib
import datetime
from bs4 import BeautifulSoup
class EarningsAnnouncement:
def __init__(self, Company, Ticker, EPSEst, AnnouncementDate, AnnouncementTime):
self.Company = Company
self.Ticker = Ticker
self.EPSEst = EPSEst
self.AnnouncementDate = AnnouncementDate
self.AnnouncementTime = AnnouncementTime
webBaseStr = 'http://biz.yahoo.com/research/earncal/'
earningsAnnouncements = []
dayVar = datetime.date.today()
for dte in range(1, 30):
currDay = str(dayVar.day)
currMonth = str(dayVar.month)
currYear = str(dayVar.year)
if (len(currDay)==1): currDay = '0' + currDay
if (len(currMonth)==1): currMonth = '0' + currMonth
dateStr = currYear + currMonth + currDay
webString …Run Code Online (Sandbox Code Playgroud) 我正在尝试建立一个ngrok隧道到本地运行的网络服务器端口5000服务.我可以通过localhost:5000访问网站,但是当我在端口5000上设置一个ngrok隧道时,我得到的net::ERR_CONTENT_LENGTH_MISMATCH所有css都有错误和Chrome 46.0和Safari 9.0.1中的js资源.
从Firefox 42访问ngrok链接时,我没有收到这些错误.
有谁知道为什么会这样,我可以做些什么来解决它?
我们的控制台应用程序每分钟都会向Facebook发送数百个WebRequests(使用多个应用程序和数百个访问令牌).现在,他们开始失败并在标题中显示异常消息("请求已中止:请求已取消").我们在互联网上搜索了几个小时,并尝试了所有可能的解决方案,但没有任何帮助.
这些没有帮助:
webRequest.Timeout = 20000; //A request that didn't get respond within 20 seconds is unacceptable, and we would rather just retry.
webRequest.KeepAlive = false;
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.ServicePoint.Expect100Continue = false;
Run Code Online (Sandbox Code Playgroud)
任何人有任何其他想法?
编辑:
异常的ToString:System.Net.WebException:请求已中止:请求已取消.---> System.Net.WebException:请求在System.Net.HttpWebRequest.FindServicePoint(布尔forceFind)的System.Net.ServicePointManager.FindServicePoint(Uri地址,IWebProxy代理,ProxyChain&chain,HttpAbortDelegate&abortDelegate,Int32&abortState)中被取消.在System.Net.HttpWeb上的System.Net.HttpWebRequest.DoSubmitRequestProcessing(异常和异常)处(异常E)---内部异常堆栈跟踪结束---在WebException消息的System.Net.HttpWebRequest.GetResponse()处:请求已中止:请求已取消.
edit2:我们没有达到极限.我们知道什么时候发生,问题不是那样.我们已经这样做了两年,这件事在整个过程中只发生过两次.根据AccessToken,我们每分钟只做2-3次请求,Facebook上的限制是600个请求/ accesstoken/ip.
edit3:我想为有这个或类似问题的人添加一个额外的提示:确保你处理你的RequestStream,你的Response和你的ResponseStream对象.
c# http-error system.net.webexception system.net.httpwebrequest
我试图从评论页面抓取用户对imdb影院电影的评分:(我数据库中的电影数量约为600,000).我使用jsoup来解析页面如下:(对不起,我没有在这里编写整个代码,因为它太长了)
try {
//connecting to mysql db
ResultSet res = st
.executeQuery("SELECT id, title, production_year " +
"FROM title " +
"WHERE kind_id =1 " +
"LIMIT 0 , 100000");
while (res.next()){
.......
.......
String baseUrl = "http://www.imdb.com/search/title?release_date=" +
""+year+","+year+"&title="+movieName+"" +
"&title_type=feature,short,documentary,unknown";
Document doc = Jsoup.connect(baseUrl)
.userAgent("Mozilla")
.timeout(0).get();
.....
.....
//insert ratings into database
...
Run Code Online (Sandbox Code Playgroud)
我测试了它的前100个,然后是前500个,也是我的数据库中的前2000个电影,它运行良好.但问题是,当我测试了100,000部电影时,我收到了这个错误:
org.jsoup.HttpStatusException: HTTP error fetching URL. Status=500, URL=http://www.imdb.com/search/title?release_date=1899,1899&title='Columbia'%20Close%20to%20the%20Wind&title_type=feature,short,documentary,unknown
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:449)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:167)
at imdb.main(imdb.java:47)
Run Code Online (Sandbox Code Playgroud)
我搜索了很多这个错误,我发现它是一个服务器端错误,错误号为5xx.
然后我决定设置一个条件,当连接失败时,它再尝试2次然后如果仍然无法连接,则不会停止并转到下一个URL.因为我是java的新手,所以我试图在stackoverflow中搜索类似的问题并阅读这些答案:
但是,当我按照他们的建议尝试使用"Connection.Response"时,它会告诉我"Connection.Response无法解析为某种类型".
我很感激,如果有人可以帮助我,因为我只是一个新手,我知道它可能很简单,但我不知道如何解决它. …
我刚刚在VS2013中使用框架3.5创建了一个WCF服务应用程序.用于公开我在类库项目中使用的一些方法.
一切都很顺利,但当我试图查看服务是否运行时,它没有.相反,我得到了下一个错误.
HTTP错误404.17 - 未找到请求的内容似乎是脚本,静态文件处理程序不会提供.
最有可能的原因是:请求与通配符mime映射匹配.请求将映射到静态文件处理程序.如果有不同的前提条件,请求将映射到不同的处理程序.
您可以尝试的事项:如果要将此内容作为静态文件提供,请添加显式MIME映射.
我已经在IIS上处理了它,但是现在在IIS Expres我有点迷失了.
我没有在这台机器上安装IIS,因为我使用的是遥控器,但我需要调试一些东西而且我被卡住了.谢谢你的帮助.
我也用visual命令提示符运行了servicesmodelreg -i,但是错误仍然存在.
UPDATE
它可能是有用的澄清它只发生在IIS Express中,因此它正在影响开发.我已将VS2013更新到Win 8.1 64bit上运行的最新补丁
在过去的几个月里,当我们分别尝试通过端口8080和7990连接到托管JIRA和Stash的内部服务器时,我们遇到了间歇性的102错误.
我不熟悉Java堆栈,但我相信在机器上安装JIRA时,它会设置Catalina Tomcat服务器.
我找不到任何有用的日志来表明任何问题.我可以采取哪些步骤来诊断此问题?
HTTP 501错误是否适合服务器计划支持的功能,但目前不支持,例如API的特定情况?例如,如果我正在设计一个网络邮件应用程序并且我还无法删除带有附件的电子邮件,那么如果我在带有附件的电子邮件上收到DELETE请求,是否适合给予501?
RFC表示它应该用于未知方法(例如PARTY请求),但不清楚它是否应该用于其他功能.
我已经在本地机器(Windows 10)上的 IIS(版本 10)上成功发布了一个 ASP.NET Core 网站并浏览了它。
但是,当我将它部署在另一台 PC 上的 IIS 上(使用相同版本)时,它给出了HTTP 错误 500.19:
我使用的是相同的Web.config,并IIS_IUSRS有两个虚拟目录和配置文件的权限。我还将应用程序池“IIS AppPool/MyPool”的权限添加到虚拟目录中。这是 web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\IdentityServer.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
什么是问题?
问题: 我正在尝试使用 google colab python 笔记本读取存储在我的项目的云存储桶之一中的 .gz JSON 文件,但我不断收到此错误:
HttpError: Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object., 401
Run Code Online (Sandbox Code Playgroud)
我的代码:
fs = gcsfs.GCSFileSystem(project='my-project')
with fs.open('bucket/path.json.gz') as f:
gz = gzip.GzipFile(fileobj=f)
file_as_string = gz.read()
json_a = json.loads(file_as_string)
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有这些身份验证方法,但仍然收到相同的 401 错误:
!gcloud auth login
!gcloud auth list
!gcloud projects list
!gcloud config set project 'myproject-id'
Run Code Online (Sandbox Code Playgroud)
from google.colab import auth
auth.authenticate_user()
Run Code Online (Sandbox Code Playgroud)
!gcloud config set account 'my GCP email'
Run Code Online (Sandbox Code Playgroud)
!gcloud auth activate-service-account
Run Code Online (Sandbox Code Playgroud)
!gcloud auth application-default login
Run Code Online (Sandbox Code Playgroud)
!gsutil config
Run Code Online (Sandbox Code Playgroud)
!gcloud …Run Code Online (Sandbox Code Playgroud) python json http-error google-cloud-storage google-cloud-platform
http-error ×10
http ×2
python ×2
asp.net ×1
asp.net-core ×1
c# ×1
catalina ×1
iis ×1
iis-express ×1
java ×1
jira ×1
json ×1
jsoup ×1
networking ×1
ngrok ×1
open-uri ×1
ruby ×1
tomcat ×1
tunnel ×1
wcf ×1
web-crawler ×1
webserver ×1