Results 1 to 5 of 5

Thread: Httpwebrequest Sucks!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2013
    Posts
    2

    Httpwebrequest Sucks!!!!

    Tried to do something with httpwebrequest 1-2 times it got worked but after that it started returning 403 forbidden error? y? and i tried that same code in new project and its working tried like 10 times and still working, now i can't just export my whole 3.5k lines of to that new project? and what if it also stopped working again? i'm making an bot here for instagram using webstagram:

    some codes:
    Code:
    Public Function method_0(ByVal string_0 As String, ByVal string_1 As String, ByVal string_2 As String, ByVal string_3 As String) As String
            Dim str3 As String = ""
            Dim responseHeader As String = ""
            Me.httpWebRequest_0 = Nothing
            Dim requestStream As Stream = Nothing
            Dim response As HttpWebResponse = Nothing
            Dim responseStream As Stream = Nothing
            Try
                GC.Collect()
                Dim requestUri As New Uri(string_0, UriKind.Absolute)
                Me.httpWebRequest_0 = DirectCast(WebRequest.Create(requestUri), HttpWebRequest)
                Me.httpWebRequest_0.ServicePoint.UseNagleAlgorithm = False
                Me.httpWebRequest_0.ServicePoint.Expect100Continue = False
                Me.httpWebRequest_0.ServicePoint.ConnectionLimit = &HFDE8
                Me.httpWebRequest_0.ServicePoint.MaxIdleTime = 500
                Me.httpWebRequest_0.CookieContainer = cookieContainer_0
                Me.httpWebRequest_0.Referer = string_1
                Me.httpWebRequest_0.KeepAlive = True
                Me.httpWebRequest_0.ReadWriteTimeout = 360000
                Me.httpWebRequest_0.Connection = "keepalive"
                Me.httpWebRequest_0.Pipelined = True   
                 Me.httpWebRequest_0.Headers.Set("Cache-Control", "max-age=0")
                Me.httpWebRequest_0.AutomaticDecompression = (DecompressionMethods.Deflate Or DecompressionMethods.GZip)
                Me.httpWebRequest_0.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
                Me.httpWebRequest_0.UserAgent = "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
                Me.httpWebRequest_0.UnsafeAuthenticatedConnectionSharing = True
                Me.httpWebRequest_0.AuthenticationLevel = AuthenticationLevel.None
                Me.httpWebRequest_0.Timeout = 360000
                Me.httpWebRequest_0.AllowAutoRedirect = True
                Me.httpWebRequest_0.PreAuthenticate = True
                Me.httpWebRequest_0.AllowWriteStreamBuffering = False
                Me.httpWebRequest_0.ProtocolVersion = HttpVersion.Version11
                If (string_2 <> "") Then
                    Me.httpWebRequest_0.Method = "POST"
                    Me.httpWebRequest_0.ContentType = "application/x-www-form-urlencoded"
                    Dim bytes As Byte() = Encoding.UTF8.GetBytes(string_2.ToString)
                    Me.httpWebRequest_0.ContentLength = bytes.Length
                    requestStream = Me.httpWebRequest_0.GetRequestStream
                    requestStream.Write(bytes, 0, bytes.Length)
                    requestStream.Flush()
                    requestStream.Close()
                Else
                    Me.httpWebRequest_0.Method = "GET"
                    Me.httpWebRequest_0.ContentLength = 0
                End If
                response = DirectCast(Me.httpWebRequest_0.GetResponse, HttpWebResponse)
                Dim response2 As HttpWebResponse = response
                Select Case response2.StatusCode
                    Case HttpStatusCode.MovedPermanently, HttpStatusCode.Found, HttpStatusCode.SeeOther, HttpStatusCode.TemporaryRedirect
                        responseHeader = response2.GetResponseHeader("Location")
                        If Not responseHeader.Contains("err200.html") Then
                            Exit Select
                        End If
                        str3 = "retry"
                        GoTo Label_040C
                    Case HttpStatusCode.OK
                        responseStream = response2.GetResponseStream
                        Dim reader As New StreamReader(responseStream, Encoding.UTF8)
                        str3 = reader.ReadToEnd
                        reader.Close()
                        responseStream.Close()
                        reader = Nothing
                        responseStream = Nothing
                        GoTo Label_040C
                    Case Else
                        str3 = "retry"
                        GoTo Label_040C
                End Select
                str3 = responseHeader
    Label_040C:
                response2 = Nothing
                response.Close()
                response = Nothing
                Me.httpWebRequest_0 = Nothing
                If (str3 = "") Then
                    str3 = "retry"
                End If
            Catch exception1 As WebException
                MsgBox(exception1.Message)
                GC.Collect()
                str3 = exception1.Message
            Catch exception3 As Exception
                MsgBox(exception3.Message)
                GC.Collect()
                str3 = exception3.Message
            Finally
                If (Not requestStream Is Nothing) Then
                    requestStream.Close()
                    requestStream.Dispose()
                    requestStream = Nothing
                End If
                If (Not responseStream Is Nothing) Then
                    responseStream.Close()
                    responseStream.Dispose()
                    responseStream = Nothing
                End If
                If (Not response Is Nothing) Then
                    response.Close()
                    response = Nothing
                End If
                If (Not Me.httpWebRequest_0 Is Nothing) Then
                    Me.httpWebRequest_0.Abort()
                    Me.httpWebRequest_0 = Nothing
                End If
            End Try
            Return str3
        End Function
    Code:
    Private httpWebRequest_0 As HttpWebRequest = Nothing
        Dim cookieContainer_0 As New CookieContainer
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
    WebBrowser1.DocumentText = method_0("http://websta.me/login", "http://websta.me", "", "")
    Dim flag As Boolean = False
            Dim flag2 As Boolean = False
            Dim temp As String = "https://instagram.com"
            Dim temp2 As String = ""
            For Each frm As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
                If frm.Id.Equals("login-form") Then
                    temp += frm.GetAttribute("action")
                   flag = True
               End If
            Next
            For Each frm As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
                If frm.Name.Equals("csrfmiddlewaretoken") Then
                    temp2 = frm.GetAttribute("value")
                    flag2 = True
                    Exit For
                End If
           Next
    
    WebBrowser1.DocumentText = method_0(temp, "https://instagram.com", "csrfmiddlewaretoken=" + temp2 + "&username=username&password=password", "")
    this above code is working in new project but not working in my main bot project which has multithreading with multiple proxies support, i want to know what is blocking this httpwebrequest on that particular bot project only? and also that webbrowser is also working fine but problem with webbrowser is it don't support multiple proxies at same time and just because of this only i'm shiffting to httpwebrequest but its not working

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Httpwebrequest Sucks!!!!

    Ok so what we have to view all the code you did not write just find a bug of an application that is not allowed here? You clearly have just taken random snippets from the internet and chucked them together. Please take the time to learn basic coding.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Httpwebrequest Sucks!!!!

    Quote Originally Posted by Instagram Terms
    10. You must not access Instagram's private API by means other than those permitted by Instagram. Use of Instagram's API is subject to a separate set of terms available here: http://instagram.com/about/legal/terms/api/ ("API Terms").

    13. You must not interfere or disrupt the Service or servers or networks connected to the Service, including by transmitting any worms, viruses, spyware, malware or any other code of a destructive or disruptive nature. You may not inject content or code or otherwise alter or interfere with the way any Instagram page is rendered or displayed in a user's browser or device.

    15. You must not create accounts with the Service through unauthorized means, including but not limited to, by using an automated device, script, bot, spider, crawler or scraper.
    They DO have an API for interacting with Instagram... https://instagram.com/developer/ ... might be worth looking into.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Httpwebrequest Sucks!!!!

    1. Do not abuse the API. Too many requests too quickly will get your access turned off


    Use the Instagram APIs to post automated content to Instagram, including likes and comments that were not initiated and entered by an Instagram user.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: Httpwebrequest Sucks!!!!

    Please read Instagram's terms of use. In particular, these clauses:-

    8.You must not modify, adapt or hack Instagram or modify another website so as to falsely imply that it is associated with Instagram.
    9.You must not access Instagram's private API by any other means other than the Instagram application itself.
    10.You must not crawl, scrape, or otherwise cache any content from Instagram including but not limited to user profiles and photos.

    Thread closed
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width