gpt4 book ai didi

c# - StreamReader C# - 只读取特定行

转载 作者:太空宇宙 更新时间:2023-11-03 21:51:01 25 4
gpt4 key购买 nike

我正在尝试从 webResposne 中仅记录第 3 行(如果仅记录一行是不可能的,则为第 1 到第 3 行)。

这是我现在使用的代码片段。

StreamReader read = new StreamReader(myHttpWebResponse.GetResponseStream(), System.Text.Encoding.UTF8);
String result = read.ReadToEnd();
Log("Access", Server.HtmlEncode(result), "Success");

我得到以下输出

<html>
<head>
<title>Access is Granted.</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
...

等等。

我只想记录“(title>Access is Granted.(/title>”) 并且不打印任何其他内容(或该行之后的任何内容)。

我该怎么做呢?

谢谢

最佳答案

您可以将所有行读入一个数组,这样您就可以通过索引引用特定行。

关于c# - StreamReader C# - 只读取特定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14566928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com