Solved

Web Browser

Posted on 2000-04-03
11
279 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now