如何抓取html请求,请求获取网页的response,获取网页的html 怎么那么慢

bVbLkYXHttpEntity multipart = builder.build();

httppost.setEntity(multipart);

long start = System.currentTimeMillis();

// 发送请求

response = httpclient.execute(httppost);

long end = System.currentTimeMillis();

System.out.println("查询upsfreight消耗的时间是(毫秒):" + (end - start));

start = System.currentTimeMillis();

HttpEntity entity = response.getEntity();

String html = EntityUtils.toString(entity, "utf-8");

end = System.currentTimeMillis();

System.out.println("转换时间:" + (end - start));

String html = EntityUtils.toString(entity, "utf-8");

这一行代码要执行很久 4-9s,我有什么办法把他加快吗

下面是EntityUtils.toString()的方法,包为

bVbLo6Rpublic static String toString(HttpEntity entity, Charset defaultCharset) throws IOException, ParseException {

Args.notNull(entity, "Entity");

InputStream instream = entity.getContent();

if (instream == null) {

return null;

} else {

try {

Args.check(entity.getContentLength() <= 2147483647L, "HTTP entity too large to be buffered in memory");

int i = (int)entity.getContentLength();

if (i < 0) {

i = 4096;

}

Charset charset = null;

try {

ContentType contentType = ContentType.get(entity);

if (contentType != null) {

charset = contentType.getCharset();

}

} catch (UnsupportedCharsetException var13) {

if (defaultCharset == null) {

throw new UnsupportedEncodingException(var13.getMessage());

}

}

if (charset == null) {

charset = defaultCharset;

}

if (charset == null) {

charset = HTTP.DEF_CONTENT_CHARSET;

}

Reader reader = new InputStreamReader(instream, charset);

CharArrayBuffer buffer = new CharArrayBuffer(i);

char[] tmp = new char[1024];

int l;

while((l = reader.read(tmp)) != -1) {

buffer.append(tmp, 0, l);

}

String var9 = buffer.toString();

return var9;

} finally {

instream.close();

}

}

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/275438.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Serverless 究竟是什么?

大家好&#xff0c;我是若川。说起 Serverless&#xff0c;我想你应该并不陌生&#xff0c;作为一种云开发的架构模式&#xff0c;在近两年里&#xff0c;伴随着云原生概念的推广愈发火爆。作为一名 Serverless 的拥趸&#xff0c;在跟大家推荐的过程中&#xff0c;我经常能看到…

instagram.apk_评论:Instagram Reels vs.TikTok

instagram.apkWith all the attention to the newly debuted Instagram Reels from Facebook and the hilarious, bizarre world of TikTok, here’s a first impression on the two platforms and how they compare from a designer’s perspective.所有人都在关注Facebook新近…

240多个jQuery常用到的插件

概述 jQuery 是继 prototype 之后又一个优秀的 Javascript 框架。其宗旨是—写更少的代码,做更多的事情。它是轻量级的 js 库(压缩后只有21k) &#xff0c;这是其它的 js 库所不及的&#xff0c;它兼容 CSS3&#xff0c;还兼容各种浏览器&#xff08;IE 6.0, FF 1.5, Safari 2.…

华为首款鸿蒙设备正式入网,华为首款鸿蒙设备正式入网:麒麟9000+挖孔全面屏,价格感人!...

作为国内电子产品领域的巨头之一&#xff0c;华为这两年的快速发展是大众有目共睹的&#xff0c;除了手机业务外&#xff0c;华为的平板业务同样有亮眼表现&#xff0c;无独有偶&#xff0c;在近期各方媒体的不断披露之下&#xff0c;又有一款华为平板被基本确认&#xff0c;这…

早上读英语

#早上读英语# Keep your eyes on the stars and your feet on the ground. 转载于:https://www.cnblogs.com/da3j/p/10646531.html

myeclipse深色模式_完善深色模式的调色板

myeclipse深色模式Apps largely have a limited color palette which may already map well to dark mode. However, some colors produce optical vibrations when viewed on a dark background, straining the user’s eyes. So, certain apps need to map to a slightly des…

微软悄悄发布了 Web 版的 VsCode

大家好&#xff0c;我是若川&#xff0c;最近组织了源码共读活动《1个月&#xff0c;200人&#xff0c;一起读了4周源码》&#xff0c;感兴趣的可以加我微信 ruochuan12 参与&#xff0c;长期交流学习。在8月31日&#xff0c;微软发了一个介绍他们新发布的功能的帖子介绍&#…

html中样式表的三种形式,CSS样式表有几种存在方式

外部样式&#xff1a;将网页链接到外部样式表。内页样式&#xff1a;在网页上创建嵌入的样式表。行内标签样式&#xff1a;应用内嵌样式到各个网页元素标签内。每一种方法均有其优缺点&#xff1a;当要在站点上所有或部份的网页上一致地应用相同样式时&#xff0c;可使用外部样…

figma设计_设计原型的最简单方法:Figma速成课程

figma设计It doesn’t matter if you haven’t used any prototyping tools before or you’re transitioning from other ones (like Sketch, Adobe XD); This guide is for beginners and professionals alike. So for a university assignment, I had to prepare a presenta…

《大话数据结构》读后总结(九)

线性表 顺序存储结构的插入与删除 获得元素操作 #define OK 1 #define ERROR 0 #define TRUE 1 #define FALSE 0 typedef int Status; /* Status是函数的类型&#xff0c;其值是函数结果状态代码&#xff0c;如OK等 */ /* 初始条件&#xff1a;顺序线性表L已存在&#xff0c;1≤…

关于router name 的url重写 --frontname rewrite frontname重写!

对于tag 也就是在url中有tag的url&#xff0c;希望改成wholesale等其他方式&#xff0c; 1 参看blog插件方式&#xff1a; 在etc/config.xml中添加事件&#xff1a; <events> <sitemap_add_xml_block_to_the_end> <observers> …

初中级工程师如何快速成长和寻求突破

大家好&#xff0c;我是若川&#xff0c;最近组织了源码共读活动《1个月&#xff0c;200人&#xff0c;一起读了4周源码》&#xff0c;已经有超50人提交了笔记&#xff0c;群里已经有超1200人&#xff0c;感兴趣的可以加我微信 ruochuan12 参与。前言写这篇文章的初衷是因为看到…

ajax使用html()后样式无效,jquery.ajax使用字符串拼接后内联css样式失效

问题所在:是这样的,我使用ajax调用了一串json数据,使用字符串拼接的方法动态插入div容器.结果css并没有对动态插入的内容加css样式.代码描述:css使用的内联,在head部分, jquery使用外联,在body后.我尝试过:$(function(){}) //入口函数加载window.onload function(){} //原生do…

ios 按钮图片充满按钮_iOS有一些非常危险的按钮-UX评论

ios 按钮图片充满按钮I recently bought a cool thing off Amazon. It’s an adapter for iPhone, making it easy to transfer photos from your big bulky camera to your phone. The adapter itself is very easy to use: simply insert your SD card and plug the adapter …

URLScan工具配置方法第1/2页

本文分步说明如何配置 URLScan 工具以防止 Web 服务器受到攻击和利用。 如何配置 URLScan 工具察看本文应用于的产品文章编号 : 326444最后修改 : 2007年3月14日修订 : 5.3我们强烈建议所有运行 Microsoft Windows Server 2003 的用户将 Microsoft Internet 信息服务 (IIS) 升级…

poj 1809

///一个点的坐标只有四种可能&#xff0c;用0表示 偶数&#xff0c;1表示奇数 &#xff0c;则四种可能为&#xff08;0,0&#xff09;&#xff0c;&#xff08;0,1&#xff09; ///&#xff08;1,0&#xff09;&#xff0c;&#xff08;1,1&#xff09;。观察公式A|x1y2 - y1…

swiftui_SwiftUI的混合包

swiftui介绍 (Introduction) SwiftUI introduced us to a whole new way of designing and coding interfaces. Gone are the old ways of subclassing UIKit (or AppKit) classes and hardwiring layout constraints. Instead, we now have a nice, declarative way of struct…

三年经验前端社招——有赞

大家好&#xff0c;我是若川&#xff0c;祝大家中秋节快乐。最近组织了源码共读活动《1个月&#xff0c;200人&#xff0c;一起读了4周源码》&#xff0c;已经有超50人提交了笔记&#xff0c;群里已经有超1200人&#xff0c;感兴趣的可以点此链接扫码加我微信 ruochuan12 参与。…

html的 button点击事件无效,InfoWindow里面加button,监听button点击事件无效 求解啊...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼点击infoWindw中的button按钮&#xff0c;无效果&#xff1b;覆盖默认的dom结构html,body,#container {width: 100%;height: 100%;margin: 0px;}p.my-desc {margin: 5px 0;line-height: 150%;}//创建地图var map new AMap.Map(con…

4月第1周业务风控关注 |国家广播电视总局发布《未成年人节目管理规定》

易盾业务风控周报每周呈报值得关注的安全技术和事件&#xff0c;包括但不限于内容安全、移动安全、业务安全和网络安全&#xff0c;帮助企业提高警惕&#xff0c;规避这些似小实大、影响业务健康发展的安全风险。 1、国家广播电视总局发布《未成年人节目管理规定》 国家广播电视…