如何抓取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.pswp.cn/news/275438.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/275438.shtml
英文地址,請注明出處:http://en.pswp.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、國家廣播電視總局發布《未成年人節目管理規定》 國家廣播電視…