【发布时间】:2020-11-15 14:10:13
【问题描述】:
我正在尝试编写一个需要从特定标签中提取文本的 VB.Net 应用程序:
<span data-reactid="85">172,890,000</span>
然后将找到的文本 172,890,000 输入到表单上的文本框中。
在Textbox1 中,输入要搜索的股票代码。
“TTM - 总收入”的数据将始终保存在:
<span data-reactid="85">172,890,000</span> 标签。无论您查看的是什么库存。
在RichTextBox1中,是下载的url源代码。
TextBox2 是它拉“TTM”的地方。我可能会将其更改为标签,因为它是一个常量值。我不能将数字放入变量中,因为它会因公司而异,即输入到 TextBox1 中的值。
TextBox3 将显示我真正需要的价值。 172,890,000 举行
<span data-reactid="85">172,890,000</span> 标签。
我想知道如何在RichTextBox1 中搜索字符串,并在字符串末尾提取接下来的 7 个字符是否可行?
到目前为止我的代码是:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Source As String
Dim ttm1 As String
Dim ttmrev As String
Source = New System.Net.WebClient().DownloadString("https://finance.yahoo.com/quote/" + TextBox1.Text + "/financials?p=" + TextBox1.Text)
ttm1 = <span data-reactid="65">ttm</span>
ttmrev = <span data-reactid="85"></span>
RichTextBox1.Text = Source
If RichTextBox1.Find(ttm1) Then
TextBox2.Text = "ttm".ToUpper
End If
End Sub
End Class
【问题讨论】:
标签: vb.net web-scraping yahoo-finance