在多线程程序中使用Jsoup出现400个Http错误 [英] 400 Http Errors Using Jsoup in Multithreaded Program

查看:63
本文介绍了在多线程程序中使用Jsoup出现400个Http错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个解析html页面的程序.我在ThreadPool中的可调用类中使用jsoup connect函数.问题是我连接到同一个网站,并且线程池的大小为5+,我收到IO异常-400个错误.

I've created a program that parses html pages. I use jsoup connect function within a callable class inside ThreadPool. The problem is that I'm connecting to the same website and with a thread pool size of 5+, I get IO Exceptions - 400 errors.

我如何做到这一点?

推荐答案

如果您收到400 HTTP响应,请检查响应的内容以获取错误消息. 400表示某种错误的请求:您没有包括所有必需的信息或畸形的信息.当客户做了他们不喜欢的事情时,有些人还把它当作一种包罗万象的东西.如果您提出许多不同的请求,请检查导致400的请求,看看它们是否有问题.如果它们看起来都不错,或者您要重复发送相同的请求,则可能是您所访问的站点具有某种速率限制,使您无法在特定时间范围内发出太多并发请求或太多请求.如果是这样,我希望响应中会显示一条消息,告诉您发生了什么事情.

If you're getting a 400 HTTP response, check the content of the response for an error message. A 400 means a bad request of some kind: you didn't include all the required information or included malformed information. Some people also use it as kind of a catch-all for when the client did something they don't like. If you're making lots of different requests, examine the ones that caused 400's to see if there's something wrong with them. If they all look right or if you're sending the same requests repeatedly, then maybe the site you're hitting has some kind of rate limiting that disallows you from making too many concurrent requests or too many requests within a particular timeframe. If it's something like that, I'd expect there to be a message in the response telling you what's going on.

这篇关于在多线程程序中使用Jsoup出现400个Http错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆