Solved

Web Browser

Posted on 2000-04-03
11
283 Views
Last Modified: 2013-11-13
I would like create a web browser that will strip out all graphics. It will basically just show all text, much like Lynxx Browser for Unix. I need to connect to a proxy server.
0
Comment
Question by:VBNewbie
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 1

Expert Comment

by:ATM
ID: 2681088
You can use this code to retrieve HTML source. When You directly use winsock, its potentially too much faster than if use other components.

Public JobURL As String
Public ResponseDocument As String
Public StepCount As Long
Public IsProxyUsed As Boolean
Public ServerHostIP As String
Public ServerPort As Long

'------------------------------------------------------------

Dim LocalStepCounter As Long
Dim RequestHeader As String
Dim RequestTemplate As String
'------------------------------------------------------------

Public Sub ActionStartup()
   
  If UCase(Left(JobURL, 7)) <> "HTTP://" Then
     MsgBox "Please enter url with http://", vbCritical + vbOK
     FrmActionWait.Hide
     Unload FrmActionWait
     Exit Sub
  End If
   
  LocalStepCounter = 0
  RequestHeader = ""
  RequestTemplate = "GET _$-$_$- HTTP/1.0" & Chr(13) & Chr(10) & _
                "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-comet, */*" & Chr(13) & Chr(10) & _
                "Accept-Language: en" & Chr(13) & Chr(10) & _
                "Accept-Encoding: gzip , deflate" & Chr(13) & Chr(10) & _
                "Cache-Control: no-cache" & Chr(13) & Chr(10) & _
                "Proxy-Connection: Keep-Alive" & Chr(13) & Chr(10) & _
                "User-Agent: SSM Agent 1.0" & Chr(13) & Chr(10)
   
  pureURL = Right(JobURL, Len(JobURL) - 7)
  startPos = InStr(1, pureURL, "/")
 
  If startPos < 1 Then
     ServerAddress = pureURL
     documentURI = "/"
  Else
     ServerAddress = Left(pureURL, startPos - 1)
     documentURI = Right(pureURL, Len(pureURL) - startPos + 1)
  End If
     
  If ServerAddress = "" Or documentURI = "" Then
     MsgBox "Unable to detect target page!", vbCritical + vbOK
     FrmActionWait.Hide
     Unload FrmActionWait
     Exit Sub
  End If
 
  If IsProxyUsed Then
     
      If ServerHostIP = "" Then
         MsgBox "Unable to detect proxy address!", vbCritical + vbOK
         FrmActionWait.Hide
         Unload FrmActionWait
         Exit Sub
      End If
     
      RequestHeader = RequestTemplate & "Host: @$@@$@" & Chr(13) & Chr(10)
      RequestHeader = Replace(RequestHeader, "@$@@$@", ServerAddress)
      RequestHeader = Replace(RequestHeader, "_$-$_$-", JobURL)
  Else
      ServerHostIP = ServerAddress
      ServerPort = 80
      RequestHeader = RequestTemplate
      RequestHeader = Replace(RequestHeader, "_$-$_$-", documentURI)
  End If
 
  Me.Show
  RequestHeader = RequestHeader & Chr(13) & Chr(10)
  TxtStatus.Text = "Connecting to server ..."
  TxtStatus.Refresh
   
  WS_HTTP.Connect ServerHostIP, ServerPort
End Sub

'------------------------------------------------------------
Private Sub WS_HTTP_Close()
  WS_HTTP.Close
  TxtStatus.Text = "Transaction completed ..."
  TxtStatus.Refresh
  Me.Hide
  Unload Me
End Sub

'------------------------------------------------------------
Private Sub WS_HTTP_Connect()
  WS_HTTP.SendData RequestHeader
  TxtStatus.Text = "Connected, try to obtain page ..."
  TxtStatus.Refresh
  FrmMainWin.TxtResponse.Text = ""
  FrmMainWin.TxtResponse.Refresh
End Sub

'------------------------------------------------------------
Private Sub WS_HTTP_DataArrival(ByVal bytesTotal As Long)
   Dim tmpString As String
   WS_HTTP.GetData tmpString, vbString
   FrmMainWin.TxtResponse.Text = FrmMainWin.TxtResponse.Text & tmpString
   FrmMainWin.TxtResponse.Refresh
   TxtStatus.Text = "Data from server, continue ..."
   TxtStatus.Refresh
End Sub

'------------------------------------------------------------
Private Sub WS_HTTP_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  WS_HTTP.Close
  TxtStatus.Text = "Errors occured ..."
  TxtStatus.Refresh
  Me.Hide
  Unload Me
End Sub
'------------------------------------------------------------

0
 

Author Comment

by:VBNewbie
ID: 2681199
ATM
How would you activate the code. Is there a commnad button? I was not successful running your code. Thnanks again
0
 

Author Comment

by:VBNewbie
ID: 2681217
ATM
Do I need to add a command button?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Expert Comment

by:gabester
ID: 2681220
ATM,

I don't mean to reject your answer. I didn't know how to unlock the question.
0
 

Expert Comment

by:gabester
ID: 2681221
VBNewbie
0
 

Author Comment

by:VBNewbie
ID: 2681238
How can I unreject ATMs answer?
0
 

Author Comment

by:VBNewbie
ID: 2681318
ATM
gabester is my friend and is helping with my program. He is able to write something like what you wrote but he can't seem to strip out the graphics. He has one form that with a few text boxes. He has a text box for the URL and also for the result. He has a couple command button. for exit, retrieve, and clear. I have a feeling that your answer will work, how do i unreject your answer? Sorry for the confusion.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2681744
this code shows how to scan an html document and retrieve image tags and their values.  Just adjust it to delete those tags adn reload the page with the tags deleted

http://www.vbsquare.com/tips/tip174.html
0
 
LVL 1

Accepted Solution

by:
ATM earned 150 total points
ID: 2682977
If You starts new project, open Add winsock control and add events as shown. ActionStartup is Your Command_OnClick event, change editbox names as need.
0
 
LVL 1

Expert Comment

by:ATM
ID: 2682981
+, You must set IsProxyUsed to true when use proxy server (its must be Server with no authorization), If you use proxy then set ServerHostIP and ServerPort to proxy server parameters. If no proxies used do nothing with these variables, and set IsProxyUsed to False.
0
 

Author Comment

by:VBNewbie
ID: 2684248
Thanks ATM. I really appreciate the help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question