Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2010 need help with a loop for gathering text off a website

$
0
0
i have this code that works for the first card on the website but i need it to repeat 10 time for each page right now it does the first

the output is something like
textbox1.text = "A Cell Breeding Device"
textbox2.text = "SPELL"
textbox3.text = " Continuous"
textbox4.text = "During each of your Standby Phases, put 1 A-Counter on 1 face-up monster your opponent controls."

i was thinking about just appending it to the appropriate textbox with a "," to separate them until i make them an array but i dont know how to get each one on the page to be extracted



Code:

WebBrowser1.Navigate("http://www.db.yugioh-card.com/yugiohdb/card_search.action?ope=1&sess=1&keyword=&stype=1&ctype=&starfr=&starto=&atkfr=&atkto=&deffr=&defto=&othercon=2")
        Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
            Application.DoEvents()
        Loop

        Dim StartPos1 As Integer = WebBrowser1.DocumentText.IndexOf("box_card_name")
        Dim EndPos1 As Integer = WebBrowser1.DocumentText.IndexOf("</dt>", StartPos1)
        Dim finaloutcome1 As String = WebBrowser1.DocumentText.Substring(StartPos1, EndPos1 - StartPos1) ' stil is the result
        TextBox1.Text = finaloutcome1.Replace(vbTab, "").Replace(vbCr, "").Replace(vbLf, "").Replace("  ", "").Replace("box_card_name", "").Replace("<span>", "").Replace("</span>", "").Replace("<strong>", "").Replace("&quot;", "").Replace("A&quot;", "").Replace("</strong>", "").Replace(">", "").Replace(Chr(34), "")


        Dim StartPos2 As Integer = WebBrowser1.DocumentText.IndexOf("box_card_attribute")
        Dim EndPos2 As Integer = WebBrowser1.DocumentText.IndexOf("</span>", StartPos2)
        Dim finaloutcome2 As String = WebBrowser1.DocumentText.Substring(StartPos2, EndPos2 - StartPos2) ' stil is the result 
        TextBox2.Text = finaloutcome2.Replace(vbTab, "").Replace(vbCr, "").Replace(vbLf, "").Replace("  ", "").Replace("box_card_attribute", "").Replace("><img class=", "").Replace("icon_img", "").Replace("src=", "").Replace("external/image/parts/attribute/attribute_icon_spell.png", "").Replace("alt=", "").Replace("><span>SPELL", "").Replace(" title=", "").Replace(Chr(34), "").Replace("  SPELLSPELL", "SPELL")


        Dim StartPos3 As Integer = WebBrowser1.DocumentText.IndexOf("box_card_effect")
        Dim EndPos3 As Integer = WebBrowser1.DocumentText.IndexOf("</span>", StartPos3)
        Dim finaloutcome3 As String = WebBrowser1.DocumentText.Substring(StartPos3, EndPos3 - StartPos3) ' stil is the result 
        TextBox3.Text = finaloutcome3.Replace(vbTab, "").Replace(vbCr, "").Replace(vbLf, "").Replace("  ", "").Replace("box_card_effect", "").Replace("><img class=", "").Replace("icon_img", "").Replace("src=", "").Replace("external/image/parts/effect/effect_icon_continuous.png", "").Replace("alt=", "").Replace("title=", "").Replace("><span>Continuous", "").Replace(Chr(34), "").Replace("  Continuous Continuous", " Continuous")



        Dim StartPos4 As Integer = WebBrowser1.DocumentText.IndexOf("box_card_text")
        Dim EndPos4 As Integer = WebBrowser1.DocumentText.IndexOf("</dd>", StartPos4)
        Dim finaloutcome4 As String = WebBrowser1.DocumentText.Substring(StartPos4, EndPos4 - StartPos4) ' stil is the result 
        TextBox4.Text = finaloutcome4.Replace(vbTab, "").Replace(vbCr, "").Replace(vbLf, "").Replace("  ", "").Replace("box_card_text", "").Replace(">", "").Replace(Chr(34), "")


Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>