IO.StreamReader无法读取? [英] IO.StreamReader not reading?

查看:88
本文介绍了IO.StreamReader无法读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

很多次,我都使用StreamREader来获取Web .html页面的全部内容,以便以后使用以下方法对其进行处理:

Hi everybody,

For many times I have used a StreamREader to obtain the entire content of a .html page of the web to later work with it using the following method:

Private Function GetPageText() as String
    Dim inputStr As String = ""
    Dim thiClient As New Net.WebClient
    Dim respStream As IO.Stream = Nothing
    Dim stmRd As IO.StreamReader = Nothing

    sespStream = thiClient.OpenRead("http://" & site &   filePath & "/TopPage_7500.html")

    If respStream.ReadByte() <> -1 Then
       stmRd = New IO.StreamReader(RespStream)
       inputStr = StmRd.ReadToEnd
    End If

    '****
    Return inputStr
End function



直到今天,这一直对我有效;我得到的只是这个垃圾:-
有人可以提供这方面的指导吗?该页面具有102KB的数据.这是它的开始:



This has always worked for me until today; all I am getting is this garbage: �<
Could anybody offer guidance on this matter? the page has 102KB of data. Here is the begining of it:

<html xmlns:axsl="http://localhost" lang="es">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Inicio</title>
    <style type="text/css"></style>
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <script language="JavaScript" src="/scripts/common.js" type="text/javascript"></script>
    <script language="JavaScript" src="/scripts/reload.js" type="text/javascript"></script>
    <script language="JavaScript" src="/scripts/config.js" type="text/javascript"></script>
    <link href="/css/common.css" type="text/css" rel="stylesheet">
    <script language="Javascript" type="text/javascript">
        function reloadPage(){
            location.reload();
        }
    </script>
    <script language="javascript">
        var wsMenu_jumpUrl_control = ""


;

谢谢您的时间和帮助.

致以最诚挚的问候,

Alex.


;

Thank you for your time and help.

Best regards to all,

Alex.

推荐答案

您好,Sandeep Mewara,

感谢您的帮助.我对此有100%的把握,因为在同一路径中我有另一个文件可以按预期读取.

respStream = thiClient.OpenRead("http://"& site& filePath&"/TopPage_2500.html")

从这里开始:
Hi Sandeep Mewara,

Thank you for your help. I am 100% sure of it since I have another file in the same path that is read as expected.

respStream = thiClient.OpenRead("http://" & site & filePath & "/TopPage_2500.html")

Here is begining of it:
<html lang="es">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">body {background-image:url('/images/bkg03.gif');background-repeat:repeat-x;}</style>
    <style type="text/javascript">
ids.iL.position = "absolute";
ids.iL.visibility = "hidden";
tags.td.color="white";
</style>
    <script language="javascript" type="text/javascript">
//??????????????
var brw_v = navigator.appVersion.charAt(0);
var brw_n = navigator.appName.charAt(0);
var iIE4 = false;
var iNN4 = false;
var iNN6 = false;
if((brw_v >= 4)&&(brw_n == "M"))iIE4 = true;
if((brw_v >= 4)&&(brw_v < 5)&&(brw_n == "N"))iNN4 = true;

if((brw_v >= 5)&&(brw_n == "N"))iNN6 = true;
var Laymax = 4; //?????????
var layX = 250; //?????????
var layY = 0;   //?????????
var layW = 250; //???????
var layH = 100; //????????
var apos = "'"



实际上,这是这两个文件的完整路径,也许您将能够看到让我大吃一惊的内容.

工作之一:
http://200.49.137.1/abraun/PrintTest/TopPage_2075 [ http://200.49.137.1/abraun/PrintTest/TopPage_7500 [
这显然不是页面的全部内容,但是它告诉我这是一个编码问题,不幸的是,我不知道如何解决.您能提供一些建议吗?

再次感谢.



Actually, here is the complete path to both files, perhaps you will be able to see what escapes my eye.

Working one:
http://200.49.137.1/abraun/PrintTest/TopPage_2075[^]

Non-working one:
http://200.49.137.1/abraun/PrintTest/TopPage_7500[^]

Please feel free to access these pages at any time and as many times as you see fit. One thing I just noticed. The copy of the _7500.html page I have stored in the local HD does open properly in any browser when doubled clicked, but the web downloaded version returns pure garbage. Chrome even sais it is in (Simplified Han) Chinese ???? This very well may be the issue, I just do not know how to solve it.

Once again, thank you for your time Sandeep.

Alex.


Sandeep,

I have played with the encoding used by the streamreader, and using the System.Text.Encoding.BigEndianUnicode I get this: ︼html xmlns:axsl="http://localhost" lang="es">

This is obviously not the entire content of the page, but it tells me that it is an encoding issue, which unfortunately I have no idea how to solve. Could you offer some advice?

Thanks Again.


这篇关于IO.StreamReader无法读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆