我按以下脚本下载这个网站数据、得到的结果是乱码。
虽然我已添加了语言编码。
谢谢!
u="http://basic.10jqka.com.cn/600000/equity.html";d1=Open(u,HTML Table(3,Column Names(1),Data Starts(2)),Charset("gb2312"));
try something like this
u="https://www.w3schools.com/html/html_tables.asp"; blobdata = loadtextfile(u,blob); //blobdata=blobpeek(blobdata,0,47939)||hextoblob("20CDE2")||blobpeek(blobdata,47939);// insert 外 https://en.wikipedia.org/wiki/GB_2312 chardata = blobtochar(blobdata,"gb2312"); filename = savetextfile("$temp/deleteme.html",chardata); d1=Open(filename,HTML Table(1));
Download the data as a blob.
Convert the blob to character data using the GB2312 encoding.
Save the character data; it will be UTF8 encoding on disk.
Open the saved file.
the blobpeek offset was chosen very carefully to but the character here.
感谢专家!
我试着依照修改、但不能这样下载
u="http://basic.10jqka.com.cn/600000/equity.html"; txt = loadtextfile(u,blob);<BR />
它不工作。谢谢!
There might be a translation problem.
I think you are saying it did not work.
I am guessing it needs a user name and password.
If I am wrong, you'll need to give me more information.
Here's how you can supply a basic auth password.
You might need to use https instead of http.
//u = "http://basic.10jqka.com.cn/600000/equity.html"; u = "https://www.w3schools.com/html/html_tables.asp"; blobdata = New HTTP Request( URL( u ), Method( "GET" ), Username( "ross" ), Password( "Abc123" ) ) << Send( "blob" ); chardata = Blob To Char( blobdata, "gb2312" ); filename = Save Text File( "$temp/deleteme.html", chardata ); d1 = Open( filename, HTML Table( 1 ) );
请教专家:这个转码代码怎样能修改为可用的脚本?谢谢!
Function BytesToBstr(strBody, CodeBase) Dim objstream On Error Resume Next Set objstream = CreateObject("Adodb. Stream") With objstream .Type = 1 .Mode = 3 .Open .Write strBody .Position = 0 .Type = 2 .Charset = CodeBase BytesToBstr = .ReadText End With obj stream.Close Set objstream = Nothing If Err.Number <> 0 Then BytesToBstr = "" On Error GoTo 0 End Function
I don't know what that (visual basic?) code does. It looks similar to JMP's HttpRequest, and similar to earlier code in this thread that used blobToChar to do the conversion.
这个代码是将乱码转化为中文。幸好这些乱码的文字只有几个、我准备用手工操作来替换了。
好的、非常感谢专家!