Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   [решено] Поиск в строке (http://forum.oszone.net/showthread.php?t=134421)

ancoder 11-03-2009 16:05 1060648

Поиск в строке
 
Привет . Помогите с кодом.

Нужно чтобы он из исходного кода страницы выхватывал строки типа "<img src="http://--------.ru/-----/----/--------_1.jpg"
и Записывал в файл уже ссылки уже вот так "http://--------.ru/-----/----/--------_1.jpg"

Помогите пожалуйста ...

Код:

#include <INet.au3>
#include <file.au3>
_FileCreate("0.txt")


$Url = (_INetGetSource('ссылка '))

$array = StringRegExp( $Url , '<не получается с шаблоном>', 2)
for $i = 0 to UBound($array) - 1
Next


$file = FileOpen("0.txt", 1)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file ,$i)


FileClose($file)


proxy 11-03-2009 17:11 1060705

Код:

#include <IE.au3>

$oIE = _IECreate('http://www.yandex.ru/')
_IELoadWait($oIE)

$oImgs = _IEImgGetCollection ($oIE)
$iNumImg = @extended
MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page")
If $iNumImg > 0 Then
    $file = FileOpen("0.txt", 1)
    If $file = -1 Then MsgBox(64, 'Ошибка', 'При открытие файла возникла ошибка')
    For $oImg In $oImgs
        MsgBox(0, "Img Info", "src=" & $oImg.src)
        FileWriteLine($file, $oImg.src & @CRLF)
    Next
    FileClose($file)
EndIf


beve 11-03-2009 18:41 1060810

Цитата:

Цитата ancoder
Привет . Помогите с кодом.
Нужно чтобы он из исходного кода страницы выхватывал строки типа "<img src="http://--------.ru/-----/----/--------_1.jpg"
и Записывал в файл уже ссылки уже вот так "http://--------.ru/-----/----/--------_1.jpg" »

Вот, примерно так, если действовать по твоей задумке:
Код:

#include <INet.au3>
#include <array.au3>
;ссилку взял первую попавшуюся
$sUrl = _INetGetSource('http://dogdraw.narod.ru/links.html')

$sArray =
StringRegExp( $sUrl , '.*<img src="(http://.*?.jpg).*',3,1)
$sSsilki=
_ArrayToString($sArray, @CRLF, 0, UBound($sArray) - 1)

$sFile="0.txt"
$fOpen=FileOpen($sFile,1)
FileWrite($fOpen,$sSsilki)
FileClose($sFile)



ancoder 11-03-2009 18:54 1060825

Спасибо огромное !!!

proxy 11-03-2009 18:58 1060830

смотри выше - пример от beve :)


Время: 21:24.

Время: 21:24.
© OSzone.net 2001-