I was able to successfully read dynamic information from a website through the second link shown (it is commented out in the code below).
If I uncomment out the second line of this code, the code works fine, and I get information from the website that I want.
If I use the code as-is, with the first web link, then it doesn't work. The file that gets generated is 0 bytes. (if you run the code for the first time, you might have to press some button, then you might have to run the script again--that all depends on the browser).
So how to get the desired result?
I also tried _RSSGetInfo, and that didn't work either (also shown below; The shipper seemed to indicate that the information was an RSS feed, and it was XML, so I didn't know whether this was the right thing to use or not, but it gave me a blank)....
#include <MsgBoxConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <Date.au3>
#include <String.au3>
#include <Excel.au3>
#include <WinAPIFiles.au3>
$Link = "http://wcf.mscgva.ch/publicasmx/Tracking.asmx/GetRSSTrackingByContainerNumber?ContainerNumber=MSCU4727397"
;$Link = "https://www.hapag-lloyd.com/en/online-business/tracing/tracing-by-booking.html?blno=HLCUEUR1810BCLY1"
$file = fileopen(@ScriptDir & "\XYZ.txt", 2 + 8)
$IE = _IECreate($Link, 0, 1, 1, 1)
Sleep(2000)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
MsgBox(0, "Source", $source)
Here is the RSSInfo version, which gives me a blank (I found this on the internet, and edited it)
#include <MsgBoxConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <Date.au3>
#include <String.au3>
#include <Excel.au3>
#include <WinAPIFiles.au3>
#include-once
#region _RSS
; RSS Reader
; Created By: Frostfel
#include <INet.au3>
#include <Array.au3>
; ============================================================================
; Function: _RSSGetInfo($RSS, $RSS_InfoS, $RSS_InfoE[, $RSS_Info_ = 1])
; Description: Gets RSS Info
; Parameter(s): $RSS = RSS Feed Example: "http://feed.com/index.xml"
; $RSS_InfoS = String to find for info start Example: <title>
; $RSS_InfoE = String to find for info end Example: </title>
; $RSS_Info_Start = [optional] <info>/</info> To start at
; Some RSS feeds will have page titles
; you dont want Defualt = 0
; Requirement(s): None
; Return Value(s): On Success - Returns RSS Info in Array Starting at 1
; On Failure - Returns 0
; @Error = 1 - Failed to get RSS Feed
; Author(s): Frostfel
; ============================================================================
Func _RSSGetInfo($RSS, $RSS_InfoS, $RSS_InfoE, $RSS_Info_Start = 0)
$RSSFile = _INetGetSource($RSS)
If @Error Then
SetError(1)
Return -1
EndIf
Dim $InfoSearchS = 1
Dim $Info[1000]
Dim $InfoNumA
$InfoNum = $RSS_Info_Start
While $InfoSearchS <> 6
$InfoNum += 1
$InfoNumA += 1
$InfoSearchS = StringInStr($RSSFile, $RSS_InfoS, 0, $InfoNum)
$InfoSearchE = StringInStr($RSSFile, $RSS_InfoE, 0, $InfoNum)
$InfoSearchS += 6
$InfoSS = StringTrimLeft($RSSFile, $InfoSearchS)
$InfoSearchE -= 1
$InfoSE_Len = StringLen(StringTrimLeft($RSSFile, $InfoSearchE))
$InfoSE = StringTrimRight($InfoSS, $InfoSE_Len)
_ArrayInsert($Info, $InfoNumA, $InfoSE)
WEnd
Return $Info
EndFunc
#endregion
$Link = "http://wcf.mscgva.ch/publicasmx/Tracking.asmx/GetRSSTrackingByContainerNumber?ContainerNumber=MSCU4727397"
$Test1 = _RSSGetInfo($Link, "<channel>", "</channel>", 1)
MsgBox(0, "Test", $Test1)
Aucun commentaire:
Enregistrer un commentaire