0

VB.netで簡単なアプリを作成して、Webサイトから情報を収集し、その結果をアプリに電子メールで送信させようとしています。目的は、トナーが交換されたときにプリンターからページ数を収集することです。必要なデータのXPATHを持っていますが、VBでこれを使用する方法を理解できませんでした。(プログラミングの経験はほとんどありません)。

これまでのところ、アプリがプリンターポータルにログインし、必要な情報を含むWebページを表示しています。この情報のXPATHは次のとおりです。

// * [@ id = "contents"] / div [3] / div / table / tbody / tr [1] / td

このテーブルセルから数値を抽出して解析するのを手伝ってくれる人はいますか?

あなたたちが与えることができるどんな助けにも感謝します!

4

1 に答える 1

0

ストリームリーダーを使用できます!この例を見てください:

        Dim inStream As StreamReader
        Dim webRequest As WebRequest
        Dim webresponse As WebResponse


        webRequest = webRequest.Create("YOUR URL TO THE PAGE GOES HERE")
        webresponse = webRequest.GetResponse()
        inStream = New StreamReader(webresponse.GetResponseStream())
        Dim sourcecode As String = inStream.ReadToEnd()
        Dim x1 As Integer = sourcecode.IndexOf("<td>Nr. of toner changed:") + 25 '25 is the number of characters in the string to search
        Dim x2 As Integer = sourcecode.IndexOf("times </td>") 'what comes right after your search string. has to be unique in the page

        dim nuberofchanges as integer = sourcecode.Substring(x1, x2 - x1)

お役に立てれば!:)

于 2013-02-02T11:35:14.823 に答える