从HTML web文档.NET获取文本
基本上我想做的是从HTML web文档中获取文本从HTML web文档.NET获取文本,html,vb.net,text,web,document,Html,Vb.net,Text,Web,Document,基本上我想做的是从HTML web文档中获取文本 <a href="showthread.php?tid=2632829">1</a> <a href="showthread.php?tid=2342818">1</a> <a href="showthread.php?tid=2342818">1</a> <a href="showthread.php?tid=2342818">1</a> .
<a href="showthread.php?tid=2632829">1</a>
<a href="showthread.php?tid=2342818">1</a>
<a href="showthread.php?tid=2342818">1</a>
<a href="showthread.php?tid=2342818">1</a>
....
....
然后我想把它们一行一行地放在richtextbox中
说
到目前为止,我所做的是使用
source = WebBrowser1.DocumentText.ToString()
早些时候,我使用了一些运气
dim ss,variable as string
variable = ss.Substring(ss.LastIndexOfAny(">1</a> ") - 27, 27)
output:
showthread.php?tid=11digitnumber
dim ss,变量为字符串
变量=ss.子字符串(ss.LastIndexOfAny(“>1”)-27,27)
输出:
showthread.php?tid=11digitnumber
但是我只能使用一次,而且文档中有很多这样的文件,你只需要使用一些逻辑,比如:
myOriginPoint = your starting point (usually 0)
myLastOccurrence = your last point (usually with LastIndexOf)
然后可以使用循环和临时列表,如:
List<String> urls = new List<String>();
while(myOriginPoint < myLastOccurrence )
{
//retrieve the keyword
var urlFound = your logic to retrieve the url
//save the keyword
urls.Add(urlFound);
//move to next position
myOriginPoint = indexOf +1;
}
List url=new List();
while(myOriginPoint
顺便说一句,您也可以在.Net中使用WebClient,从url检索数据要好得多:
我希望这会有所帮助,你只需要运用一些逻辑,比如:
myOriginPoint = your starting point (usually 0)
myLastOccurrence = your last point (usually with LastIndexOf)
然后可以使用循环和临时列表,如:
List<String> urls = new List<String>();
while(myOriginPoint < myLastOccurrence )
{
//retrieve the keyword
var urlFound = your logic to retrieve the url
//save the keyword
urls.Add(urlFound);
//move to next position
myOriginPoint = indexOf +1;
}
List url=new List();
while(myOriginPoint
顺便说一句,您也可以在.Net中使用WebClient,从url检索数据要好得多:
我希望这能有所帮助,您使用webbrowser是因为您需要向用户显示流程,还是因为您不知道获取网页源代码的任何其他方式?您使用webbrowser是因为您需要向用户显示流程,还是因为您不知道获取网页源代码的任何其他方式?