Jump to content
Sign in to follow this  
flxfxp

Using regxp to grab certain url?

Recommended Posts

flxfxp

Hello,

I would like to use _INetGetSource to grab <a href="http://tc.versiontracker.com/product/redir/lid/1557732/wrar380.exeWinRAR" title="Download WinRAR"> from http://www.versiontracker.com/dyn/moreinfo/win/10007677 using regular expressions. I would only like to match on the a href with the exe in it.

I have the following code:

#include <Inet.au3>

$source = _INetGetSource("http://www.versiontracker.com/dyn/moreinfo/win/10007677")
                    $singlequote = Chr(39)
                    $XPIRegExp = '<a href=' & $singlequote & '(.*\.exe*)' & $singlequote & ' title=' & $singlequote & '*' & $singlequote & ''
                    $ret = StringRegExp($source,$XPIRegExp,3)
MsgBox(1, "regxp used", $XPIRegExp)
MsgBox(1, "result", $ret[0])

Can anyone help?

Thanks!

Dennis

Edited by flxfxp

Share this post


Link to post
Share on other sites
SmOke_N

"(?i)<a href=\x22http:[\w/\.]+\.exe\w.+?>"


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
flxfxp

never mind, i fixed it with the following:

#include <Inet.au3>

$source = _INetGetSource("http://www.versiontracker.com/dyn/moreinfo/win/10007677")
                    $singlequote = Chr(39)
                    $doublequote = Chr(34)
                    ;$XPIRegExp = '<a href=' & $singlequote & '(.*\.exe*)'
                    ;<a href="(.*\.exe.*)" title=".*?"
                    $XPIRegExp = '<a href=' & $doublequote & '(.*\.exe.*)' & $doublequote & ' title=' & $doublequote & '.*?' & $doublequote & '><'
                    $ret = StringRegExp($source,$XPIRegExp,1)
MsgBox(1, "regxp used", $XPIRegExp)
MsgBox(1, "result", $ret[0])

$sourcedl = _INetGetSource($ret[0])
                    ;window.location.href = '(.*\.exe)'
                    $XPIRegExpdl = 'window.location.href = ' & $singlequote & '(.*\.exe)' & $singlequote & ''
                    $retdl = StringRegExp($sourcedl,$XPIRegExpdl,3)
MsgBox(1, "regxp used", $XPIRegExpdl)
MsgBox(1, "result", $retdl[0])

Share this post


Link to post
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
Sign in to follow this  

×