Jump to content

Using regxp to grab certain url?


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

"(?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.

Link to comment
Share on other sites

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])
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...