| |
Fortgeschrittene Programmierungnmea Datei Map über gpsvisualizer erstellen und Downloadlink ermitteln | | | Autor: Hubert Holler | Datum: 13.06.19 23:19 |
| Hallo!
Ich möchte anhand einer nmea Datei (https://www.dropbox.com/s/0p8y02pse4nf2o7/2019-06-13_121144.674.as.nmea?dl=0) über gpsvisualizer.com eine Map erstellen, wo ich dann den Downloadlink für die Karte ermitteln möchte.
Dazu habe ich bis jetzt immer folgenden Code verwendet, der auch immer funktioniert hat.
Laut gpsvisualizer wurde die Seite jetzt auf https geändert. Ich habe meiner Meinung nach alle Änderungen angepasst.
Hier mein Code
Public Function gpslink(datei As String) As String
Dim strFile As String
Dim strHttp As String
Dim DestUrl As URL
'Dim datei As String
'datei = "D:\eigene dateien\vb\datenlogger - totorovic\nmea.txt"
strdatei = Mid(datei, InStrRev(datei, "\", -1) + 1)
strUrl = "https://www.gpsvisualizer.com/map?output_home"
strName = "uploaded_file_1"
strMIMEType = "multipart/form-data"
' if a request is allredy being sent
' exit
If blnConnected Then Exit Function
' check that a file was selected
If datei = vbNullString Then
MsgBox "No File Chosen", vbCritical, "ERROR"
Exit Function
End If
' extract the URL using a helper function
DestUrl = ExtractUrl(strUrl)
If DestUrl.Host = vbNullString Then
MsgBox "Invalid Host", vbCritical, "ERROR"
Exit Function
End If
' clear the old response
strResponse = ""
' read the file contents as a string
' N.B: in HTTP everything is a string, even binary files
strFile = GetFileContents(datei)
' build the HTTP request
strHttp = BuildFileUploadRequest(strFile, DestUrl, strName, strdatei, _
strMIMEType)
' assign the protocol host and port
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = DestUrl.Host
If DestUrl.Port <> 0 Then
Winsock1.RemotePort = DestUrl.Port
Else
Winsock1.RemotePort = 80
End If
' make the connection and send the HTTP request
Winsock1.Connect
While Not blnConnected
DoEvents
Wend
strRequest = strHttp
Winsock1.SendData strHttp
While blnConnected
DoEvents
Wend
'Clipboard.SetText strResponse
'Debug.Print Len(strResponse)
Dim intview As Integer
Dim pfad As String
intview = InStr(1, strResponse, "view")
If intview > 0 Then
pfad = Mid(strResponse, 1, intview - 3)
gpslink = Mid(pfad, InStrRev(pfad, "/", -1))
gpslink = "https://www.gpsvisualizer.com/display" & gpslink & " "
Else
gpslink = ""
End If
If blnConnected Then blnConnected = False
End Function | |
Re: nmea Datei Map über gpsvisualizer erstellen und Downloadlink ermitteln | | | Autor: Hubert Holler | Datum: 13.06.19 23:19 |
| Private Function BuildFileUploadRequest(ByRef strData As String, _
ByRef DestUrl As URL, _
ByVal UploadName As String, _
ByVal FileName As String, _
ByVal MimeType As String) As String
Dim strHttp As String ' holds the entire HTTP request
Dim strBoundary As String 'the boundary between each entity
Dim strBody As String ' holds the body of the HTTP request
Dim lngLength As Long ' the length of the HTTP request
' create a boundary consisting of a random string
strBoundary = RandomAlphaNumString(32)
' create the body of the http request in the form
'
' --boundary
' Content-Disposition: form-data; name="UploadName"; filename="FileName"
' Content-Type: MimeType
'
' file data here
'--boundary--
strBody = "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""" & UploadName _
& """; filename=""" & _
FileName & """" & vbCrLf
strBody = strBody & "Content-Type: " & MimeType & vbCrLf
strBody = strBody & vbCrLf & strData
strBody = strBody & vbCrLf & "--" & strBoundary & "--"
' find the length of the request body - this is required for the
' Content-Length header
lngLength = Len(strBody)
' construct the HTTP request in the form:
'
' POST /path/to/reosurce HTTP/1.0
' Host: host
' Content-Type: multipart-form-data, boundary=boundary
' Content-Length: len(strbody)
'
' HTTP request body
strHttp = "POST " & DestUrl.URI & "?" & DestUrl.Query & " HTTP/1.0" & vbCrLf
strHttp = strHttp & "Host: " & DestUrl.Host & vbCrLf
strHttp = strHttp & "Content-Type: multipart/form-data, boundary=" & _
strBoundary & vbCrLf
strHttp = strHttp & "Content-Length: " & lngLength & vbCrLf & vbCrLf
strHttp = strHttp & strBody
BuildFileUploadRequest = strHttp
End Function Bei strResponse sollte ich nun die entsprechende Seite erhlaten, wo ich im Quellcode bei dem Wort "view" den Link finden kann.
Jetzt bekomme ich aber bei strResponse folgendes Ergebnis:
-------------
HTTP/1.1 302 Found
Date: Thu, 13 Jun 2019 20:05:43 GMT
Server: Apache/2.2.15 (CentOS)
Location: https://www.gpsvisualizer.com/map?output_home
Content-Length: 229
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved here.</p>
</body></html>
-----------
Hoffe es kann mir jemand weiterhelfen, wo der Fehler liegen könnte.
Vielen Dank | |
Siehe auch | | | Autor: VB3-Guru | Datum: 16.06.19 14:49 |
| Siehe auch
http://foren.activevb.de/forum/vb-classic/thread-412492/beitrag-412492/Formularaufruf-ueber-gpsvisuali/#forum | |
Re: Siehe auch | | | Autor: Hubert Holler | Datum: 17.06.19 22:34 |
| Danke für die Antwot.
Nur da kam leider auch keine Antwort. | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
sevZIP40 Pro DLL
Zippen und Unzippen wie die Profis!
Mit nur wenigen Zeilen Code statten Sie Ihre Anwendungen ab sofort mit schnellen Zip- und Unzip-Funktionen aus. Hierbei lassen sich entweder einzelnen Dateien oder auch gesamte Ordner zippen bzw. entpacken. Weitere InfosTipp des Monats Access-Tools Vol.1
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
Copyright ©2000-2024 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|