如何抓取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;这…

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;微软发了一个介绍他们新发布的功能的帖子介绍&#…

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…

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

大家好&#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 …

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…

数据挖掘 点击更多 界面_8(更多)技巧,可快速改善用户界面

数据挖掘 点击更多 界面重点 (Top highlight)Creating beautiful, usable, and efficient UIs takes time, with many design revisions along the way. Making those constant tweaks to produce something that your clients, users, and yourself are truly happy with. I k…

三年经验前端社招——腾讯微保

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

matlab绘制路线图_绘制国际水域路线图

matlab绘制路线图Two years ago, Shopify was only available in English. Few people in Germany or Japan had heard about us. We had only just formed the international growth team to make Shopify available to people in their native tongue.两年前&#xff0c;Shop…

2021年江苏高考各科成绩查询,江苏2021年高考总分及各科分数

江苏2021年高考总分及各科分数2021-04-16 08:46:02文/董月江苏高考将实施“33”模式&#xff0c;即语数外三门必考&#xff0c;然后在物理、化学、生物、历史、政治、地理六门学科中任选三门进行考试&#xff0c;并计入总分。“6选3”中的3门以等级确定&#xff0c;折算成分数计…

figma下载_通过构建7个通用UI动画来掌握Figma中的动画

figma下载Originally published on my personal blog.最初发布在我的 个人博客上 。 Most designers will spend many hours perfecting every pixel of their static UI designs but will barely spend any time perfecting the transitions between these pages.大多数设计人…

怎么用计算机上的打印设备打印,电脑中怎么添加打印机设备

电脑中怎么添加打印机设备电脑中怎么添加打印机设备呢&#xff0c;下面小编介绍一下。具体如下&#xff1a;1. 打开电脑&#xff0c;点击“控制面板”图标2. 在如图页面&#xff0c;找到“硬件和声音”&#xff0c;点击打开3. 然后点击”设备和打印机“选项4. 打开后&#xff0…

三年经验前端社招——朴朴科技

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