473,684 Members | 3,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest from behind a proxy

Hi

I have been struggling with what should be a simple thing. I want to
crawl the web for specific links, and save any html and files that meet
my criteria to my hard drive.

I thought that WebRequest/WebResponse would be the best way to go,
using a proxy. The page that I am returned is just a proxy generated
file, and not the source code. Is there any way around this?

As a workaround, I used the AxWebBrowser and an mshtml document. this
works well, except when I come to downloading files. As stated above,
the easy options don't work - WebRequest/WebRespose return a 404:File
not Found error (which you would expect, given that it doesn't get to
the html), webclient doesn't work behind a proxy AND after doing some
searching, it is proving difficult to programmaticall y download linked
files using AxWebbrowser.

So, my questions to the smart people out there include:

a) is there any way to get the webrequest/webresponse objects working
behind a proxy when only proxy generated source is returned to the
WebRequest object 9and not the file source code) - could this be
anything to do with proxy authorisation?;

b) is there a way to programatticall y download pdf files using
AxWebbrowser?

Grateful for any advice.

Cheers

James

Dec 20 '05 #1
5 3459
<ja*********@de wr.gov.au> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
b) is there a way to programatticall y download pdf files using
AxWebbrowser?

Grateful for any advice.


Can't you just use the TcpClient class to get the page? The syntax is very
simple and you get the full text of the page back unprocessed, so you can do
what you like with it. All you need to do is send:

GET /pagename.htm HTTP/1.1
HOST: nameofhost.com

then 2 crlfs.

Michael
Dec 20 '05 #2
Does this help?

http://support.microsoft.com/default...301102&SD=MSDN

Yosh
<ja*********@de wr.gov.au> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
Hi

I have been struggling with what should be a simple thing. I want to
crawl the web for specific links, and save any html and files that meet
my criteria to my hard drive.

I thought that WebRequest/WebResponse would be the best way to go,
using a proxy. The page that I am returned is just a proxy generated
file, and not the source code. Is there any way around this?

As a workaround, I used the AxWebBrowser and an mshtml document. this
works well, except when I come to downloading files. As stated above,
the easy options don't work - WebRequest/WebRespose return a 404:File
not Found error (which you would expect, given that it doesn't get to
the html), webclient doesn't work behind a proxy AND after doing some
searching, it is proving difficult to programmaticall y download linked
files using AxWebbrowser.

So, my questions to the smart people out there include:

a) is there any way to get the webrequest/webresponse objects working
behind a proxy when only proxy generated source is returned to the
WebRequest object 9and not the file source code) - could this be
anything to do with proxy authorisation?;

b) is there a way to programatticall y download pdf files using
AxWebbrowser?

Grateful for any advice.

Cheers

James

Dec 20 '05 #3
Thanks Yosh - yes I had seen that and tried webrequest etc, but
couldn't get through.

Michael - could you provide more information (or links to more
information) on how to set a simple TCPClient up - haven't done it
before.

Thanks

James

Yosh wrote:
Does this help?

http://support.microsoft.com/default...301102&SD=MSDN

Yosh
<ja*********@de wr.gov.au> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
Hi

I have been struggling with what should be a simple thing. I want to
crawl the web for specific links, and save any html and files that meet
my criteria to my hard drive.

I thought that WebRequest/WebResponse would be the best way to go,
using a proxy. The page that I am returned is just a proxy generated
file, and not the source code. Is there any way around this?

As a workaround, I used the AxWebBrowser and an mshtml document. this
works well, except when I come to downloading files. As stated above,
the easy options don't work - WebRequest/WebRespose return a 404:File
not Found error (which you would expect, given that it doesn't get to
the html), webclient doesn't work behind a proxy AND after doing some
searching, it is proving difficult to programmaticall y download linked
files using AxWebbrowser.

So, my questions to the smart people out there include:

a) is there any way to get the webrequest/webresponse objects working
behind a proxy when only proxy generated source is returned to the
WebRequest object 9and not the file source code) - could this be
anything to do with proxy authorisation?;

b) is there a way to programatticall y download pdf files using
AxWebbrowser?

Grateful for any advice.

Cheers

James


Dec 20 '05 #4
<ja*********@de wr.gov.au> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Thanks Yosh - yes I had seen that and tried webrequest etc, but
couldn't get through.

Michael - could you provide more information (or links to more
information) on how to set a simple TCPClient up - haven't done it
before.


Note the slash after the GET is the page you're requesting, in this case the
default page for MS.

TcpClient client = new TcpClient();
client.Connect( "www.microsoft. com", 80);
NetworkStream stream = client.GetStrea m();
byte[] data = System.Text.ASC IIEncoding.ASCI I.GetBytes("GET /
HTTP/1.1\r\nHOST: microsoft.com\r \n\r\n");
stream.Write(da ta, 0, data.Length);
data = new byte[256];
int len = 0;
do
{
len = stream.Read(dat a, 0, 256);
Console.WriteLi ne(System.Text. ASCIIEncoding.A SCII.GetString( data, 0, len));
}while(len == 256);
stream.Close();
client.Close();

Michael
Dec 20 '05 #5
Thanks Michael - that code worked beautifully. I have also found
another proxy server I can use which allows me to use WebRequest and
WebResponse, so case closed ...

Dec 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6961
by: Matthias Kwiedor | last post by:
I try to get a page from a https server. I can build up a connection with WebRequest and everything runs fine without setting a proxy. After setting a proxy, i get the error that i can't build a thrusted connection to the remote server. If i try it over the IE i get a pop up which tells me the same, but i can override it! Anyone has i idea? i need that in combination with a cookiecontainer! Code:
1
10029
by: Pete Davis | last post by:
First of all, I apologize. I wanted to post this in microsoft.public.dotnet.framework (as it's a bit more appropriate there), but Outlook Express is suddenly giving me errors whenever I go to that newsgroup and I have to restart OE. I'm using WebRequest and I want to bypass any caching in the proxy server. Unfortunately, I don't have a proxy to test with. My understanding is that I just need to pass a pragma: no-cache and...
1
3163
by: Tim Regan | last post by:
Hi All, I'm writing an app using WebRequest in csharp. I need the app to respond to the host PC moving from one network to another, e.g. taking a laptop home after work. Currently the WebRequest.Proxy is always picked up from the work network settings, so that the GetResponse method throws a WebException when the proxy is unreachable. But IE works fine across the two networks. I've two questions.
1
1227
by: DWrek | last post by:
Hi Everyone, I have a .NET dll that uses the HTTPWebRequest class to make an HTTP connection to an off-site server. This dll works just fine from a Winform but when I try to use it from an ASP page (via COM Interop) and get a registry access exception. I know why this happening. The dll makes the request using the following: request = CType(WebRequest.Create(url), HttpWebRequest)
4
7228
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
2
6466
by: davidcbrown | last post by:
I started using .NET 2003 and my first application is to parse an HTML form. But I am behind an ISA firewall and get "(407) Proxy Authentication Required" with the following code. The proxy settings in webReq.Proxy appear to be OK, even without setting them as below. IE works, but this does not. Any ideas? (or where to ask?) -- David Dim webReq As WebRequest = WebRequest.Create(txtUrl.Text) webReq.Proxy = WebProxy.GetDefaultProxy Dim...
6
12480
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my HTTP based command to the server:
2
2146
by: heatstor | last post by:
Hi, When using the webrequest object, is there a way to make the source ip anonymous before connecting to a URL/website. Any help will be appreciated. Asim.
2
5966
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like this: System.Net.WebClient client=new System.Net.WebClient();
0
8504
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8772
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7584
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4521
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.