Hallo,
das von SUeBo geschriebene Script zum auslesen von bestimmten Daten aus einer dynamisch erstellten Website ist bereits getestet worden und hat mit einigen Ausnahmen bestanden.
Allerdings gibt es Probleme mit manchen Unterordnern. Die meißten verfügen über 3, manche jedoch nur um 2. Daher fallen diese raus und werden nicht erfasst.
Hier ein Link zur Website auf die sich das Programm bezieht: http://www.offtek.de
Benötigt werden hier alle Informationen der Laptop Speicher, vom Modelname bis hin zum Preis eines jeden Moduls. Das sind etwa 200.000 Module.
Wenn jemand dabei helfen kann, das Script so umzuschreiben, dass es wirklich alle MarkenModelle einlesen kann, wäre ich sehr dankbar.
Spoiler anzeigen
C
#include <Array.au3>
#include <Excel.au3>
HotKeySet("!{n}", "_Exit")
$sSource = __InetGetSource("http://www.offtek.de/laptopmemory.php?maincat=1&stid=1")
$aManufact = StringRegExp($sSource, "(?<=href=')(\QModelType.php?stid=1&manu=\E([\w/-]+))", 3)
If @error Then Exit
;~ _ArrayDisplay($aManufact)
Global $aExcel[1][9] = [["Speichermodul", "Modulgröße", "Produkt-Kode", "Herst.-Kode", "Spezifikationen", "Marke", "Lagerstatus", "Garantie", "Preis"]]
For $m = 0 To UBound($aManufact) - 1 Step 2
ConsoleWrite("+>===================================================================" & @CRLF)
TrayTip($aManufact[$m + 1], "Wir sind beim nächsten Hersteller!", 10)
$sSource = __InetGetSource("http://www.offtek.de/" & $aManufact[$m])
$aTyp = StringRegExp($sSource, "(?<=modeltype=).+?(?='>)", 3)
If @error Then ContinueLoop
;~ _ArrayDisplay($aTyp)
For $t = 0 To UBound($aTyp) - 1
TrayTip($aManufact[$m + 1], "Modeltype: " & $aTyp[$t], 3)
If Not StringInStr($aTyp[$t], "&model=") Then
$sSource = __InetGetSource("http://www.offtek.de/ModelSelect.php?stid=1&manu=" & $aManufact[$m] & "&modeltype=" & $aTyp[$t])
$aModel = StringRegExp($sSource, "model=([^']+)", 3)
If @error Then ContinueLoop
For $mo = 0 To UBound($aModel) - 1
$sSource = __InetGetSource("http://www.offtek.de/ModelData.php?stid=1&manu=" & $aManufact[$m] & "&modeltype=" & $aTyp[$t] & "&model=" & $aModel[$mo])
$aTitle = StringRegExp($sSource, 'class="titlebar">Speichermodule f.r (.+)</td>', 3)
$aData = StringRegExp($sSource, "(?>middle'>([^<]+)).+?(?>middle'>([^<]+)).+?(?>middle'>([^<]+)).+?(?>a href='[^>]+>(.+?)</a>)(?>.+?returnValue"">([^<]+))(?>.+?returnValue""> ?([^<]+))(?>.+?returnValue"">([^<]+))(?>.+?(\d+,\d+) ?&euro)", 4)
For $x = 0 To UBound($aData) - 1
_AddModul($aTitle[0], $aData[$x])
Next
;~ _ArrayDisplay($aExcel)
ConsoleWrite("http://www.offtek.de/ModelData.php?stid=1&manu=" & $aManufact[$m] & "&modeltype=" & $aTyp[$t] & "&model=" & $aModel[$mo] & @CRLF)
Next
Else
$sSource = __InetGetSource("http://www.offtek.de/ModelSelect.php?stid=1&manu=" & $aManufact[$m] & "&modeltype=0&model=" & $aTyp[$t])
$aTitle = StringRegExp($sSource, 'class="titlebar">Speichermodule f.r (.+)</td>', 3)
$aData = StringRegExp($sSource, "(?>middle'>([^<]+)).+?(?>middle'>([^<]+)).+?(?>middle'>([^<]+)).+?(?>a href='[^>]+>(.+?)</a>)(?>.+?returnValue"">([^<]+))(?>.+?returnValue""> ?([^<]+))(?>.+?returnValue"">([^<]+))(?>.+?(\d+,\d+) ?&euro)", 4)
For $x = 0 To UBound($aData) - 1
_AddModul($aTitle[0], $aData[$x])
Next
ConsoleWrite("http://www.offtek.de/ModelSelect.php?stid=1&manu=" & $aManufact[$m] & "&modeltype=0&model=" & $aTyp[$t] & @CRLF)
EndIf
ConsoleWrite(@CRLF)
Next
ConsoleWrite("+>===================================================================" & @CRLF)
ConsoleWrite(@CRLF & @CRLF)
Next
_ArrayDisplay($aExcel)
$oExcelObj = _ExcelBookNew()
_ExcelWriteSheetFromArray($oExcelObj, $aExcel)
_ExcelBookClose($oExcelObj)
Func __InetGetSource($s_URL)
Local $sString = InetRead($s_URL)
Local $nError = @error, $nExtended = @extended
Return SetError($nError, $nExtended, BinaryToString($sString))
EndFunc ;==>__InetGetSource
Func _AddModul($sName, $aArray)
$iUbound = UBound($aExcel)
ReDim $aExcel[$iUbound + 1][9]
$aExcel[$iUbound][0] = $sName
For $i = 1 To UBound($aArray) - 1
$aExcel[$iUbound][$i] = $aArray[$i]
Next
EndFunc ;==>_AddModul
Func _Exit()
Exit
EndFunc ;==>_Exit
Alles anzeigen
Mfg
Botaner