signup
login
tour
help
Dismiss
AnnouncingStackOverflowDocumentation
WestartedwithQ&[Link],andweneedyourhelp.
Whetheryou'reabeginneroranexperienceddeveloper,youcancontribute.
Signupandstarthelping
LearnmoreaboutDocumentation
[Link]
[Link]?Iwanttogettheresultofarequestlike[Link]
ip=[Link]
[Link] httpget
askedSep18'08at13:28
notandy
2,542
6Answers
[Link]:
[Link]
DimresultAsString=[Link]("[Link]
ip=[Link]")
InC#:
[Link]=[Link]();
stringresult=[Link]("[Link]
editedMar23'12at16:05
answeredSep18'08at13:31
hangy
8,502
31
53
[Link]=[Link]() canbeabbreviatedto Dim
[Link] can'tit? MattLyons Nov29'11at22:36
@MattLyonsYes,[Link] AsString from DimresultAsString=... ,butI'lljust
[Link] Mar23'12at16:07
Whatifthewebpagerequiresausernameandpassword? Matt Jan9'13at18:26
1 @MattUse HttpWebRequest andsetthe Credentials propertytoanewinstanceof
NetworkCredential . hangy Jan9'13at19:00
YoucanusetheHttpWebRequestclasstoperformarequestandretrievearesponsefroma
[Link]'lluseitlike:
Try
[Link]
DimtargetURIAsNewUri("[Link]
fr=DirectCast([Link](targetURI),[Link])
If([Link]().ContentLength>0)Then
[Link]([Link]().GetResponseStream())
[Link]([Link]())
[Link]();
EndIf
[Link]
'Errorinaccessingtheresource,handleit
EndTry
HttpWebRequestisdetailedat:[Link]
us/library/[Link]
AsecondoptionistousetheWebClientclass,thisprovidesaneasiertouseinterfacefor
downloadingwebresourcesbutisnotasflexibleasHttpWebRequest:
SubMain()
'AddressofURL
DimURLAsString=[Link]
'GetHTMLdata
DimclientAsWebClient=NewWebClient()
17
27
DimdataAsStream=[Link](URL)
DimreaderAsStreamReader=NewStreamReader(data)
DimstrAsString=""
str=[Link]()
[Link]>0
[Link](str)
str=[Link]()
Loop
EndSub
Moreinfoonthewebclientcanbefoundat:[Link]
us/library/[Link]
editedSep18'08at13:48
answeredSep18'08at13:37
Wolfwyrd
10k
26
1 [Link]()infirstexamplethenallgood.CorgaloreOct31'11at19:42
WebClientisaquicksolution,[Link]
imagesmetadatafromremoteresources:Iavoidedtodownloadtheimagesintothefs,andIusedthe
ResponseStreaminsted.AlbertoDeCaroJun6'12at13:51
1 [Link]([Link]()) [Link] Jan27'14at13:10
usethewebrequestclass
thisistogetanimage
Try
Dim_WebRequestAsSystem.[Link]=Nothing
_WebRequest=[Link]([Link]
CatchexAsException
[Link]([Link])
ExitSub
EndTry
Try
_NormalImage=
[Link](_WebRequest.GetResponse().GetResponseStream())
CatchexAsException
[Link]([Link])
ExitSub
EndTry
answeredSep18'08at13:32
chrissie1
3,247
Theeasiestwayis
DownloadString .
[Link]
editedJun9'12at22:31
11
17
22
or
answeredSep18'08at13:32
SiddharthRout
89.8k
OliverMellet
102
145
1,506
13
YoushouldtrytheHttpWebRequest
class.
answeredSep18'08at13:29
DarioSolera
3,462
19
32
Trythis:
WebRequestrequest=[Link](RequestUrl);
[Link]="GET";
WebResponseresponse;
try{response=[Link]();}
catch(WebExceptionexc){response=[Link];}
if(response==null)
thrownewHttpException((int)[Link],"Therequestedurlcouldnotbe
found.");
using(StreamReaderreader=newStreamReader([Link]())){
stringrequestedText=[Link]();
//dowhatyouwantwithrequestedText
}
SorryabouttheC#,IknowyouaskedforVB,butIdidn'thavetimetoconvert.
61
answeredSep18'08at13:36
NickBerardi
39.1k
12
93
122