Jump to content

(.NET) Browsing the web w/o WebBrowser

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
scheda

scheda

    Newbie

  • Members
  • Pip
  • 5 posts
Is there a way to access web pages without WebBrowser?

Say for instance I wanted to access a website, do a search, and pull the results into my application.

Is there another component, or something, I could use to gain access to that site?

Thanks for your help.

#2
semprance

semprance

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
You could read the webpage into a string and then parse it with RegEx. You'd be better doing this with some sort of XML or json feed if the site you want to read has one.

#3
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
you can use:
Dim mywebclient as new Net.Webclient
Dim content as String = mywebclient.downloadstring("the url")


#4
semprance

semprance

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts

Vswe said:

you can use:
Dim mywebclient as new Net.Webclient
Dim content as String = mywebclient.downloadstring("the url")

Csharpification:

WebClient client = new WebClient();
string foo = client.DownloadString("http://www.website.com/file.txt");
Also, try DownloadStringAsync if you're multithreading (best when downloading large files).

Edited by semprance, 07 April 2010 - 02:03 PM.
Extra CODE tag snuck in...


#5
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
oops, misread the section it was posted in, thought it was VB. But yeah that is the C# version.