Jump to content

Recommended Posts

Good morning,

I'm making progress, slowly understand regular expressions. Today I started to have fun also with an array. All expressions of landing to a file. OK!

Now I have to add each line first element that will result a complete URL.

The hope in you.

Ps. Please give the command for now, trying to finally learn something;)

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp('href="/account/5086.html">', '(?i)<A class=i href="(.*?)"',3)
For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next
$oee =_ArrayDisplay($oe, "1D display")            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <------------- trza zobaczyc f1 instrukcje helpu 
$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe[$i], 1)

; Display the file.
ShellExecute($sFilePath)

 

Link to comment
Share on other sites

Test.txt:

<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="/get/13131231.html">
<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">
<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)
For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next
$oee =_ArrayDisplay($oe, "1D display")            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <------------- trza zobaczyc f1 instrukcje helpu 
$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe[$i], 1)

; Display the file.
ShellExecute($sFilePath)

They r wroten as /get/123123.html - i would add data before them to make whole url from _IEPropertyGet($oIE, "locationurl"))

Edited by galan2015
Link to comment
Share on other sites

Not sure if this is what you are looking for or not, as I am not sure where you are getting the correct URL...can you show us a complete URL?

 

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)
_ArrayDisplay($oe, "1D display")

For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
$oe[$i] = 'newURL.' & $i & '.html'
MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next

$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe)

; Display the file.
ShellExecute($sFilePath)

 

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

 

$oe[$i] = 'newURL.' & $i & '.html'
 

 

If your guess is accurate, i think this should be

$oe[$i] = 'newURL.' & $oe[$i] & '.html'

 

 

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Global $oe[3]

$oe[0] = stringregexp('<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="/get/13131231.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]
$oe[1] = stringregexp('<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]
$oe[2] = stringregexp('<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]

For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
$oe[$i] = 'newURL.com' & $oe[$i]
MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I was not sure, I was j

 

If your guess is accurate, i think this should be

$oe[$i] = 'newURL.' & $oe[$i] & '.html'

That could be, but was just showing where OP would enter the new info.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Guys u dont understand. I want every record that "stringRegExp" had the address that is currently displayed page at $ oie

This is page what im training my skillz

 

Func ZapiszHtmlPodglad() ; Przycisk Skanuj
local $url = _IEPropertyGet($oIE, "locationurl") ; <------- http://warsaw.craigslist.pl/search/eve

FileWrite( @ScriptDir& "\test.txt", _IEBodyReadHTML($oIE))
$adresyogloszen = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)

For $i = 0 To UBound($adresyogloszen) - 1
$sFilePath = @ScriptDir & "\test2.txt"
FileWrite(@ScriptDir& '\test2.txt',$url&$adresyogloszen[$i])
_FileWriteFromArray($sFilePath, $adresyogloszen, 1)
Next
EndFunc

 

Edited by galan2015
Link to comment
Share on other sites

?

#Include <Array.au3>

$url = "http://www.myurl.com"

$sHtml = '<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="http://example.com/url.php">' & @CRLF & _
         '<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' & @CRLF & _
         '<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">'

$sHtml = StringRegExpReplace($sHtml, '(?iU)<a class=i href="\K(?!http)', $url)
         
$aLinks = StringRegExp($sHtml, '(?iU)<a class=i href="(.+)"', 3)
_ArrayDisplay($aLinks)

 

Link to comment
Share on other sites

?

#Include <Array.au3>

$url = "http://www.myurl.com"

$sHtml = '<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="http://example.com/url.php">' & @CRLF & _
         '<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' & @CRLF & _
         '<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">'

$sHtml = StringRegExpReplace($sHtml, '(?iU)<a class=i href="\K(?!http)', $url)
         
$aLinks = StringRegExp($sHtml, '(?iU)<a class=i href="(.+)"', 3)
_ArrayDisplay($aLinks)

 

​Thank you, next question.

If the result of StringRegExp does not include search activity how can I skip the rest of tasks? I know i should use Something like that:
Func Lolo()
Local $file1= StringRegExp(FileRead($newsdata), '<DIV class=news>(.*?)</DIV></UL>',3)
If $file1 = 1 then ; He found it
For $i = 0 To UBound($file1) - 1
MsgBox(1,1,$file1[$i])
FileWrite($newsdata,$file1[$i]&@CRLF)
ElseIf $file1 = 0 then ; not found 
EndFunc ; just if Just If the program does find anything, I would like to end the function.
Endif
Endfuc
Just If the program does find anything, I would like to end the function.
 

 

Link to comment
Share on other sites

$file1 cannot be equal to 1 because StringRegExp with option 3 ($STR_REGEXPARRAYGLOBALMATCH) returns either an array or 0 (and @error is set to 1 or 2).

You can test if $file1 is an array : If IsArray($file1) Then ..., or test if @error is set or no : If Not @error Then ...

 

Link to comment
Share on other sites

$file1 cannot be equal to 1 because StringRegExp with option 3 ($STR_REGEXPARRAYGLOBALMATCH) returns either an array or 0 (and @error is set to 1 or 2).

You can test if $file1 is an array : If IsArray($file1) Then ..., or test if @error is set or no : If Not @error Then ...

 

​BUt i dont know how write it ;s

Link to comment
Share on other sites

Func Lolo()
    Local $file1 = StringRegExp(FileRead($newsdata), '<DIV class=news>(.*?)</DIV></UL>',3)
    If @error Then Return ; Or If Not IsArray($file1)
    
    For $i = 0 To UBound($file1) - 1
        MsgBox(0, "", $file1[$i])
        FileWrite($newsdata,$file1[$i]&@CRLF) ; Are you sure you what to write in the same file ?
    Next
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...