Autoit 无法识别 _StringBetween 函数
Autoit doesn't recognize _StringBetween function
我的代码崩溃了,指出 _StringBetween 不是可识别的函数,即使我定义了所需的正确#include。它不会在第一个 _StringBetween 上崩溃,但会在下一个上崩溃。 _StringBetween 都以蓝色字体出现在编辑器上,确认拼写正确,参数数量正确....我很困惑...
见下面的代码。 Stack Exchange 迫使我添加更多描述,因此您现在可以跳转到代码部分。
代码:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.5
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
;"C:\install\AutoIt3.exe" "C:\ArgsTest.au3" /argumentOne:MyFirstValue /argumentTwo:MySecondValue
#include <MsgBoxConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <Date.au3>
#include <String.au3>
#include <Excel.au3>
#include <WinAPIFiles.au3>
$BOL = 'HLCUEUR1810BCLY1'
$Tankno = '6001505'
$Link = "https://www.hapag-lloyd.com/en/online-business/tracing/tracing-by-booking.html"
$Link = $Link & "?blno=" & $BOL
;MsgBox($MB_ICONINFORMATION, "Tutorial", $BOL)
$file = fileopen(@scriptdir & "\HL3.txt", 10)
$IE = _IECreate($Link, 0, 1)
Sleep (200)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
;extracting the value needed
$target_source = _StringBetween($source, $Tankno, '</tr>')
$year = _StringBetween(target_source[0],$Tankno, "-")
$year = StringRight($year,4)
$month = _StringBetween($target_source[0],$year & '-', '-')
$day = _StringBetween($target_source[0],$year & "-" & $month & "-","<")
$day = StringLeft($day,2)
$ETA = $year & $month & $day
MsgBox($MB_ICONINFORMATION, "Tutorial", $ETA)
;$target_source2 = _StringBetween($target_source[0], '<td', '/td>')
;$target_source3 = _StringBetween($target_source2[0], '>', '<')
;$USDEUR = $target_source3[0]
这不是最干净的方法,但它是获取您正在寻找的年-月-日值的解决方案:
改进代码:
#include-once
#include <Array.au3>
#include <Date.au3>
#include <Excel.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <WinAPIFiles.au3>
$BOL = 'HLCUEUR1810BCLY1'
$Tankno = '6001505'
$Link = "https://www.hapag-lloyd.com/en/online-business/tracing/tracing-by-booking.html"
$Link = $Link & "?blno=" & $BOL
$file = fileopen(@ScriptDir & "\HL3.txt", 2 + 8)
$IE = _IECreate($Link, 0, 1, 1, 1)
Sleep(2000)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
$target_source = _StringBetween($source, $Tankno, '</tr>')
$aETA = StringRegExp($target_source[0], '(\d{4})-(\d{2})-(\d{2})', 3)
_ArrayDisplay($aETA) ; this is optional (see array content)
$ETA = $aETA[0] & $aETA[1] & $aETA[2]
MsgBox($MB_ICONINFORMATION, "Tutorial", $ETA)
请注意:
您的线路 $year = _StringBetween(target_source[0],$Tankno, "-")
不正确。您忘记了 $
作为 $target_source 的可变指标。所以 _StringBetween()
函数不是问题所在。我决定使用 RegEx 表达式过滤 $target_source
,而不是再次使用 _StringBetween() 作为年-月-日值。
我的代码崩溃了,指出 _StringBetween 不是可识别的函数,即使我定义了所需的正确#include。它不会在第一个 _StringBetween 上崩溃,但会在下一个上崩溃。 _StringBetween 都以蓝色字体出现在编辑器上,确认拼写正确,参数数量正确....我很困惑...
见下面的代码。 Stack Exchange 迫使我添加更多描述,因此您现在可以跳转到代码部分。
代码:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.5
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
;"C:\install\AutoIt3.exe" "C:\ArgsTest.au3" /argumentOne:MyFirstValue /argumentTwo:MySecondValue
#include <MsgBoxConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <Date.au3>
#include <String.au3>
#include <Excel.au3>
#include <WinAPIFiles.au3>
$BOL = 'HLCUEUR1810BCLY1'
$Tankno = '6001505'
$Link = "https://www.hapag-lloyd.com/en/online-business/tracing/tracing-by-booking.html"
$Link = $Link & "?blno=" & $BOL
;MsgBox($MB_ICONINFORMATION, "Tutorial", $BOL)
$file = fileopen(@scriptdir & "\HL3.txt", 10)
$IE = _IECreate($Link, 0, 1)
Sleep (200)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
;extracting the value needed
$target_source = _StringBetween($source, $Tankno, '</tr>')
$year = _StringBetween(target_source[0],$Tankno, "-")
$year = StringRight($year,4)
$month = _StringBetween($target_source[0],$year & '-', '-')
$day = _StringBetween($target_source[0],$year & "-" & $month & "-","<")
$day = StringLeft($day,2)
$ETA = $year & $month & $day
MsgBox($MB_ICONINFORMATION, "Tutorial", $ETA)
;$target_source2 = _StringBetween($target_source[0], '<td', '/td>')
;$target_source3 = _StringBetween($target_source2[0], '>', '<')
;$USDEUR = $target_source3[0]
这不是最干净的方法,但它是获取您正在寻找的年-月-日值的解决方案:
改进代码:
#include-once
#include <Array.au3>
#include <Date.au3>
#include <Excel.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <WinAPIFiles.au3>
$BOL = 'HLCUEUR1810BCLY1'
$Tankno = '6001505'
$Link = "https://www.hapag-lloyd.com/en/online-business/tracing/tracing-by-booking.html"
$Link = $Link & "?blno=" & $BOL
$file = fileopen(@ScriptDir & "\HL3.txt", 2 + 8)
$IE = _IECreate($Link, 0, 1, 1, 1)
Sleep(2000)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
$target_source = _StringBetween($source, $Tankno, '</tr>')
$aETA = StringRegExp($target_source[0], '(\d{4})-(\d{2})-(\d{2})', 3)
_ArrayDisplay($aETA) ; this is optional (see array content)
$ETA = $aETA[0] & $aETA[1] & $aETA[2]
MsgBox($MB_ICONINFORMATION, "Tutorial", $ETA)
请注意:
您的线路 $year = _StringBetween(target_source[0],$Tankno, "-")
不正确。您忘记了 $
作为 $target_source 的可变指标。所以 _StringBetween()
函数不是问题所在。我决定使用 RegEx 表达式过滤 $target_source
,而不是再次使用 _StringBetween() 作为年-月-日值。