Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 28th, 2003, 06:50 AM
thewinchester thewinchester is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Perth, WA, Australia
Posts: 2 thewinchester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Proxy Auth. in this VB script

I'm on the hunt for a little help here. I have written this piece of VB script to scrap a graphic from a web page and save it to my local server.

However, this script was written with a fair bit of help from my friends - and i'm not much of a programmer. This script has to run on a corporate network which all web traffic goes out via our proxy which requires authentication.

Does anyone know of a method where I can get this script to pipe all it's request out via a proxy, and if it is possible to specify authentication details for the proxy server.

All and any help greatly appreciated.

Michael

====
Dim Inet, strHTML, Pos1, Pos2

strHTML = getHttpFile("http://www.unitedmedia.com/comics/dilbert/archive/")
strHTML = GetDilbert(strHTML)
BinarySaveURL strHTML, "dir\filename.ext"

Function GetDilbert(strHTML)
strHTML = getHttpFile("http://www.unitedmedia.com/comics/dilbert/archive/")
Pos1 = InStr(strHTML, "/comics/dilbert/archive/images/dilbert")
If pos1=0 then
Response.Write("Sorry, page did not load...ReTrying")
Response.Redirect("DailyDilbert.asp")
Else
Pos2 = InStr(pos1,strhtml, ".gif")
strHTML = Mid(strHTML, Pos1, (Pos2+4 )- Pos1)
strHTML="http://www.unitedmedia.com" & strhtml
End If
GetDilbert =strHTML
End Function

Function GetHTTPFile(File)
Dim DLText
Set DLText = CreateObject("WinHttp.WinHttpRequest.5.1")
DLText.Open "GET", File, True
DLText.Send
If DLText.WaitForResponse(5) = True Then
GetHTTPFile = BinToStr(DLText.ResponseBody)
End If
end function

Function BinToStr(Binary)
Dim I
Dim StrOut
For I = 1 To LenB(Binary)
StrOut = StrOut & Chr(AscB(MidB(Binary, I, 1)))
Next
BinToStr = StrOut
End Function

Sub BinarySaveURL(URL, fn)
'Create an Http object, use any of the four objects
Dim Http
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")

'Send request To URL
Http.Open "GET", URL, False
Http.Send
'Get response data As a string
ss = Http.ResponseBody
Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")

'Create text stream object
Dim TextStream
Set TextStream = FS.CreateTextFile(fn)

'Convert binary data To text And write them To the file
TextStream.Write BinToStr(ss)

End Sub
======

Reply With Quote
  #2  
Old January 7th, 2004, 09:15 AM
wmetzner wmetzner is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 wmetzner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Did you ever get a solution for authenticating to the proxy server? I am having a similar issue.

Reply With Quote
  #3  
Old January 7th, 2004, 08:22 PM
thewinchester thewinchester is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Perth, WA, Australia
Posts: 2 thewinchester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nope, still hunting for a solution.

Reply With Quote
  #4  
Old March 4th, 2005, 02:47 AM
robvh robvh is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 robvh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 32 sec
Reputation Power: 0
Assuming that you still did not get an answer.

The trick is very easy.

Replace

Http.Open "GET", URL, False

with
Const HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1
Const HTTPREQUEST_PROXYSETTING_PROXY = 2
Const AutoLogonPolicy_Always = 0

Http.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "yourproxy:80", "*.intra"
Http.Open "GET", URL, False
'Http.SetCredentials "Domain\Account","*********",HTTPREQUEST_SETCREDENTIALS_FOR_PROXY
Http.SetAutoLogonPolicy AutoLogonPolicy_Always

either use setautologon to use current user for authentication, or setcredentials to specify a user and password

Hope this helps

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Proxy Auth. in this VB script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway