You are not logged in.

  • "TiamatStudios" started this thread

Posts: 1

Date of registration: Mar 7th 2013

  • Send private message

1

Thursday, March 7th 2013, 7:43am

Retrieving Website HTML

I make alot of website code parsing programs and barley learned about Jabaco. Naturally it would make my life 100 times easier if my programs were not stuck on stupid windows only. So what is a Jabaco code that can get website url similar to
the windows inet api
Example Windows Code:



Option Explicit

Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_OPEN_TYPE_DIRECT = 1
Public Const INTERNET_OPEN_TYPE_PROXY = 3

Public Const scUserAgent = "VB OpenUrl"
Public Const INTERNET_FLAG_RELOAD = &H80000000

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sURL As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long

Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer

Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer


Public Function GetURL(sURL As String) As String
Dim hOpen As Long
Dim hOpenUrl As Long
Dim bDoLoop As Boolean
Dim bRet As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String


hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hOpenUrl = InternetOpenUrl(hOpen, sURL, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)

bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend

GetURL = sBuffer
sBuffer = 0

If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Function
Is there similar code in Jabaco that anyone has? Thank you for the help!
?(

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Thursday, March 7th 2013, 11:05am

Hey there,

I found this somewhere on the board...

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Option Explicit
'Import java#io 
Private Sub Command1_Click()
   Dim a As String
   Dim b As java#net#URL 
   Dim conn As java#net#URLConnection 
   Dim c As java#io#InputStream
   Dim d As java#io#InputStreamReader
   Dim e As java#io#BufferedReader
   Dim f(1000) As String
   Dim n As Integer
   Dim outputStream As New java#io#BufferedWriter(New java#io#FileWriter("C:\tempfile.txt"))

   a = "http://www.jabaco.org/board/index.php?page=Help"
   b = New java#net#URL(a)
   conn = b.openConnection()
   c = conn.getInputStream()
   d = New java#io#InputStreamReader(c)
   e = New java#io#BufferedReader(d)
   n = 1
   Do While (n <= UBound(f)) And e.ready()
      f(n) = e.readLine()
'      Debug.Print n & ": " & f(n)
      outputStream.write  f(n)& vbCrLf
      n = n + 1
   Loop
   d.close()
   e.close()   
   Call outputStream.close()  
End Sub


hope it helps...


Dani

Rate this thread
WoltLab Burning Board