Hack Forums
[.NET] Question about Web requests.. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Question about Web requests.. (/showthread.php?tid=1410920)



Question about Web requests.. - Xaros - Jun 23, 2011

Hey guys, I had a few questions about web requests. I'm not completely sure to what their capabilities are. I actually have no clue, I was just wondering how would I implement them to get rid of browsers, they're quite annoying. Pretty much just wondering these things:

What all can they do?
When are they appropriate to be used.
How to implement them in place of a browser.


* - nathan72389 - Jun 23, 2011

and now you know why everyone suggest a person to actually learn the language rather than just "fucking around" with it.


* - Xaros - Jun 23, 2011

I was simply asking a question as I'm learning it. No need to be so hostile. I was asking a simple question about it, as the Book I'm using skimps on that part. :\


* - nathan72389 - Jun 23, 2011

(Jun 23, 2011 07:42 PM)Kickflip Wrote:  I was simply asking a question as I'm learning it. No need to be so hostile. I was asking a simple question about it, as the Book I'm using skimps on that part. :\

sry man,... you kmow how it is... 90% off everyone here, is all... "C&P., .OMG it dont work" so forgive me if i mis-read you.

gimme till tomarrow, and i will double check ur thread, and have another look at it.


* - Bigandrewgold - Jun 23, 2011

what are your web browsers doing?


* - Xaros - Jun 23, 2011

I'm looking at browsers. I'm looking at using web requests to replace web browsers..


* - Bigandrewgold - Jun 23, 2011

(Jun 23, 2011 10:28 PM)Kickflip Wrote:  I'm looking at browsers. I'm looking at using web requests to replace web browsers..

what do you mean you are looking at browsers, i am asking what does your browser, which you want to replace. currently do?


* - Xaros - Jun 23, 2011

Ah, I'm not trying to currently make something in particular. I meant I'm NOT looking at browsers, sorry. I'm just looking at how they're used to fill in information on a certain webpage. such as user, and pass etc. You understand what I'm trying to say, right?


* - Bigandrewgold - Jun 23, 2011

yeah, the best thing to do imo is use tamperdata on firefox to find out how the data is getting "POST"ed ot "GET"ed then use this function to post or get it
PHP Code

<?php 
Function WRequest(URL As String, method As String, POSTdata As String)
  
Dim responseData As String = ""
  
Try
    
Dim request As Net.HttpWebRequest = Net.WebRequest.Create(URL)
    
request.Accept = "*/*"
    
request.AllowAutoRedirect = true
    request
.UserAgent = "http_requester/0.1"
    
request.Timeout = 60000
    request
.Method = method
    
If request.Method = "POST" Then
  request
.ContentType = "application/x-www-form-urlencoded"
  
Dim encoding As New ASCIIEncoding()
  
Dim postByteArray() As Byte = encoding.GetBytes(POSTdata)
  
request.ContentLength = postByteArray.Length
  Dim postStream 
As IO.Stream = request.GetRequestStream()
  
postStream.Write(postByteArray, 0, postByteArray.Length)
  
postStream.Close()
    
End If
    
Dim response As Net.HttpWebResponse = request.GetResponse()
    If 
response.StatusCode = Net.HttpStatusCode.OK Then
  Dim responseStream 
As IO.StreamReader = _
  
New IO.StreamReader(response.GetResponseStream())
  
responseData = responseStream.ReadToEnd()
    
End If
    
response.Close()
    Catch 
e As Exception
  responseData 
= "An error occurred: " & e.Message
  End 
Try
  
WRequest = responseData
End 
Function 

and call it like this

PHP Code

<?php 
WRequest
("http://server/login", "POST", "name=jane&stat=active") 

or
PHP Code

<?php 
WRequest
("http://server/", "GET", "") 

so this could be an example for pw and email

PHP Code

<?php 
WRequest
("http://www.website.com/", "POST", "email=" & email & "&password=" & password)