We usually use external data crawling in two places, one in Asp and the other in HTA. If the external data is encoded by gb2312, it involves the issue of transcoding. However, the traditional method of using the vbs function has a relatively large amount of computation, and some special characters may even make errors.
If you use the adodb.stream control to transcode, it will be much simpler and you don’t need to use the binary processing function of vbs, and the speed is much faster.
The code copy is as follows:
<script>
functionloadData(sUrl){
varxh
xh=newActiveXObject("Microsoft.XMLHTTP")
xh.open("GET",sUrl,false)
xh.send(null)
returnb2utf8(xh.responseBody)
}
functiongb2utf8(sData){
varoStream
oStream=newActiveXObject("adodb"+".stream")
oStream.Type=1
oStream.Mode=3
oStream.Open
oStream.Write(sData)
oStream.Position=0
oStream.Type=2
oStream.Charset="GB2312"
returnStream.ReadText()
}
</script>
Articles that may be of interest to you:
Zero-Based Java Zhihu Crawler: Store the crawled content to the local Zero-Based Java Zhihu Crawler: Crawling Zhihu Answers Java Crawler Mouse Events and Mouse Scrolling Events Example Java Crawling Based on URLs and generate thumbnails java Crawling 12306 Information Implementation Train Remaining Query Example Java Crawling Web Page Data Example Java Crawling Web Page Content Implementation Code Java Crawling Web Page Data Get All Links Instances in the Web Page Sharing Java Crawling Email Address on the Web Page