faustf Posted November 12, 2015 Share Posted November 12, 2015 hi guy i have the pageweb with this part of code<td class="F13" colspan="4" align="right"> <B>1</B> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">2</a> <a href="/IT/Postal_Codes/?page=3&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">3</a> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">Successiva</a> </td> i want extract only link for successiva ( this href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0 )i use this expression but take me all(?s)</a> <a href="/IT/Postal_Codes/\?page=(.*?)">Successivasome one can help me please Link to comment Share on other sites More sharing options...
jguinch Posted November 12, 2015 Share Posted November 12, 2015 This ?#Include <Array.au3> $sHTML = '<td class="F13" colspan="4" align="right">' & @CRLF & _ '<B>1</B> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">2</a> <a href="/IT/Postal_Codes/?page=3&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">3</a> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">Successiva</a> ' & @CRLF & _ '</td>' $aLinks = StringRegExp($sHTML, '<a href=[^>]+?page=([^>]+)">Successiva</a>', 3) _ArrayDisplay($aLinks) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Danyfirex Posted November 12, 2015 Share Posted November 12, 2015 (edited) An alternative without regexp. MsgBox(0,"",StringMid($sData,StringInStr($sData,'href="',2,-1,StringInStr($sData,'">Successiva',2)),StringInStr($sData,'">Successiva',2)-StringInStr($sData,'href="',2,-1,$iPos2)))same above clean.Local $iPos2=StringInStr($sData,'">Successiva',2) Local $iPos1=StringInStr($sData,'href="',2,-1,$iPos2) MsgBox(0,"",StringMid($sData,$iPos1,$iPos2-$iPos1))where $sData is the source html... Saludos Edited November 12, 2015 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mikell Posted November 12, 2015 Share Posted November 12, 2015 If only the last link is needed a SRER does the job$sLink = StringRegExpReplace($sHTML, '(?s).*"([^"]+)">Successiva.*', "$1") Msgbox(0,"", $sLink) Link to comment Share on other sites More sharing options...
iamtheky Posted November 12, 2015 Share Posted November 12, 2015 #Include <Array.au3> $sHTML = '<td class="F13" colspan="4" align="right">' & @CRLF & _ '<B>1</B> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">2</a> <a href="/IT/Postal_Codes/?page=3&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">3</a> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">Successiva</a> ' & @CRLF & _ '</td>' $aLinks = stringsplit($sHtml , "a href" , 3) For $Link in $aLinks If stringinstr($Link , "Successiva") Then msgbox(0, '' , stringtrimright($Link , 34)) Next ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
jdelaney Posted November 13, 2015 Share Posted November 13, 2015 _IELinkGetCollectionLoop through the collection until you find yours, and get the .href. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Digisoul Posted November 13, 2015 Share Posted November 13, 2015 this can extract the last href #include <Array.au3> Local $data = '<td class="F13" colspan="4" align="right">' & @CRLF & _ '<B>1</B> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">2</a> <a href="/IT/Postal_Codes/?page=3&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">3</a> <a href="/IT/Postal_Codes/?page=2&c=AD&n=2&r0=00&r1=04&r2=00&r3=00&r4=00&o=&L=0">Successiva</a> ' & @CRLF & _ '</td>' Local $aRet = StringRegExp($data,'(?i)(?!href).*href="(.*?)">Successiva',3) _ArrayDisplay($aRet) 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now