Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

WEBBROWSER kontrola - otvaranje stranica po tajmeru

[es] :: .NET :: WEBBROWSER kontrola - otvaranje stranica po tajmeru

[ Pregleda: 1752 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

anakin14

Član broj: 73683
Poruke: 862
*.dynamic.sbb.rs.



+136 Profil

icon WEBBROWSER kontrola - otvaranje stranica po tajmeru04.05.2011. u 17:23 - pre 158 meseci
Pokusavam da napravim da mi Webcontrola na 10 sekundi menja strane.
onaj deo koda if i = 10 i if i = 20 necu tako vec cu po i da vucem iz baze string za navigaciju.
Ali ono sto ne mogu da napravim da mi uopste i za ove dve strane radi.
Poenta je da dok se to desava da se moze kretati kroz formu i koristiti tu stranu u webbrowser-u.
Kako na najbolji nacin to da izvedem?
Puno hvala!



Code:

   
    Dim thread1 As System.Threading.Thread
    
    Sub looping()
        If Me.InvokeRequired Then
            Me.Invoke(New MethodInvoker(AddressOf looping))
        Else

            Do While i <> 10000
                i = i + 1
                Label1.Text = i

                If i = 10 Then
                    WebBrowser1.Navigate("www.google.com")
                End If
                If i = 20 Then
                    WebBrowser1.Navigate("www.facebook.com")
                End If

                Me.Refresh()
                Threading.Thread.Sleep(1000)

            Loop
        End If
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        thread1 = New System.Threading.Thread(AddressOf looping)
        thread1.Start()
    End Sub

End Class



 
Odgovor na temu

Boris B.
Ljubljana

Član broj: 213615
Poruke: 286
*.evj-kabel.net.



+14 Profil

icon Re: WEBBROWSER kontrola - otvaranje stranica po tajmeru04.05.2011. u 20:40 - pre 158 meseci
Ovo izgleda kao da ce da blokira celu aplikaciju, Me.Invoke tera glavni thread da pozove looping() koji sadrzi Sleep. Drugo ne znam zasto koristis thread sa Sleepom za cekanje, koristi Timer kontrolu i njen Timer event.


if it walks like a duck and quacks like a duck, it could be a dragon doing a duck
impersonation.
 
Odgovor na temu

wex-alpha
Sarajevo

Član broj: 7580
Poruke: 845
77.78.239.*



+13 Profil

icon Re: WEBBROWSER kontrola - otvaranje stranica po tajmeru04.05.2011. u 21:27 - pre 158 meseci
ako sam dobro razumjeo...

Treba da si u stanju da parsiras/napravis scrapping stranice? i da si siguran da se ista ucitala?

Onda koristi


//Kod je c#, ali ga prilagodi :)

Code:

 webBrowser1.Navigate(new Uri("http://negdje...")); //idi na stranicu...


private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e) //osiguraj da se ista ucitala
        {


 mshtml.HTMLDocument doc3 = ((mshtml.HTMLDocument)this.webBrowser1.Document);
string[] htmlkod= a.body.innerHTML.ToString().Split('>'); 
//radi sa html-om sta zelis...
            
        }


Mozes to sve uraditi i na tezi nacin:

Code:

protected void Page_Load(object sender, EventArgs e)
    {
        //string strBuffer = "email=" + username + "&pass=" + Password + "&login=Login";
        string strBuffer = "email=xxxxxxxxxxx&pass=xxxxxxxxxxxxx;login=Login";
      
       start_post(strBuffer);
    }
 
    public void start_post(string strBuffer)
    {
        //Our postvars
        byte[] buffer = System.Text.Encoding.ASCII.GetBytes(strBuffer);
        //Initialisation

        HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("https://login.facebook.com/log...2F%2Fm.facebook.com%2Fhome.php");
        //Our method is post, otherwise the buffer (postvars) would be useless
        WebReq.Method = "POST";
        //We use form contentType, for the postvars.

        WebReq.ContentType = "application/x-www-form-urlencoded";
        //The length of the buffer (postvars) is used as contentlength.
        WebReq.ContentLength = buffer.Length;
        //We open a stream for writing the postvars
        WebReq.Referer = "http://www.facebook.com/index.php?";
 
        Stream PostData = WebReq.GetRequestStream();
        //Now we write, and afterwards, we close. Closing is always important!
        PostData.Write(buffer, 0, buffer.Length);
        PostData.Close();
        //Get the response handle, we have no true response yet!
       // HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
       // //Let's show some information about the response
       //WebResp.StatusCode;
       //WebResp.Server;

        //Now, we read the response (the string), and output it.
        using (HttpWebResponse response = (HttpWebResponse)WebReq.GetResponse())
        {
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
            Response.Write(reader.ReadToEnd());
 
            }
        }
    }


 
Odgovor na temu

anakin14

Član broj: 73683
Poruke: 862
*.dynamic.sbb.rs.



+136 Profil

icon Re: WEBBROWSER kontrola - otvaranje stranica po tajmeru05.05.2011. u 13:44 - pre 157 meseci
Citat:
Boris B.: Ovo izgleda kao da ce da blokira celu aplikaciju, Me.Invoke tera glavni thread da pozove looping() koji sadrzi Sleep. Drugo ne znam zasto koristis thread sa Sleepom za cekanje, koristi Timer kontrolu i njen Timer event.


Hvala, sa timer-om je mnogo lakse, ne znam kako mi to nije palo napamet!
 
Odgovor na temu

[es] :: .NET :: WEBBROWSER kontrola - otvaranje stranica po tajmeru

[ Pregleda: 1752 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.