Jump to content

finding an id in a link using StringRegExp?


Recommended Posts

the link is "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=9048423"

and I wan to get the 9048423 out of it but its in the entire source, any ideas?

Thanks

Edit: I dono what flags to use or the pattern

Edited by CyberZeroCool

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

smoke_ns udf just grabbed the ending, and then just got every possible character popped it in an with a bunch of Ors(|) and then yeah ahhaha easy way for me

#include <array.au3>
$sURL = "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=23423423423423423423"
Dim $szProtocol, $szDomain, $szPath, $szFile
$TestPath = _URLSplit($sURL, $szProtocol, $szDomain, $szPath, $szFile)
$reg = StringRegExp($TestPath[4],"(\w|\.|\?|\&|\d)+\=(\d+)$",1)
_ArrayDisplay($reg, 'Demo _UrlSplit()')

Func _URLSplit($szUrl, ByRef $szProtocol, ByRef $szDomain, ByRef $szPath, ByRef $szFile)
    Local $sSREPattern = '^(?s)(?i)(http|ftp|https|file)://(.*?/|.*$)(.*/){0,}(.*)$'
    Local $aUrlSRE = StringRegExp($szUrl, $sSREPattern, 2)
    If Not IsArray($aUrlSRE) Or UBound($aUrlSRE) - 1 <> 4 Then Return SetError(1, 0, 0)
    If StringRight($aUrlSRE[2], 1) = '/' Then
        $aUrlSRE[2] = StringTrimRight($aUrlSRE[2], 1)
        $aUrlSRE[3] = '/' & $aUrlSRE[3]
    EndIf
    $szProtocol = $aUrlSRE[1]
    $szDomain = $aUrlSRE[2]
    $szPath = $aUrlSRE[3]
    $szFile = $aUrlSRE[4]
    Return $aUrlSRE
EndFunc   ;==>_URLSplit
Edited by Thatsgreat2345
Link to comment
Share on other sites

smoke_ns udf just grabbed the ending, and then just got every possible character popped it in an with a bunch of Ors(|) and then yeah ahhaha easy way for me

#include <array.au3>
$sURL = "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=23423423423423423423"
Dim $szProtocol, $szDomain, $szPath, $szFile
$TestPath = _URLSplit($sURL, $szProtocol, $szDomain, $szPath, $szFile)
$reg = StringRegExp($TestPath[4],"(\w|\.|\?|\&|\d)+\=(\d+)$",1)
_ArrayDisplay($reg, 'Demo _UrlSplit()')

Func _URLSplit($szUrl, ByRef $szProtocol, ByRef $szDomain, ByRef $szPath, ByRef $szFile)
    Local $sSREPattern = '^(?s)(?i)(http|ftp|https|file)://(.*?/|.*$)(.*/){0,}(.*)$'
    Local $aUrlSRE = StringRegExp($szUrl, $sSREPattern, 2)
    If Not IsArray($aUrlSRE) Or UBound($aUrlSRE) - 1 <> 4 Then Return SetError(1, 0, 0)
    If StringRight($aUrlSRE[2], 1) = '/' Then
        $aUrlSRE[2] = StringTrimRight($aUrlSRE[2], 1)
        $aUrlSRE[3] = '/' & $aUrlSRE[3]
    EndIf
    $szProtocol = $aUrlSRE[1]
    $szDomain = $aUrlSRE[2]
    $szPath = $aUrlSRE[3]
    $szFile = $aUrlSRE[4]
    Return $aUrlSRE
EndFunc   ;==>_URLSplit
Thanks but will this work for multiple ids in the source?

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

are you going to make the entire string reg exp sample the source?

woops i cant read xD hold on

yeah so the string would be:

<div class="clear">&nbsp;</div>

<div class="left w100">

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=94243940&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl08_friendLink">Dave King</a><br>

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=94243940&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl08_friendImageLink"><img src="http://x.myspace.com/images/no_pic.gif" alt=""></a><br>

<div id="UserDataNode8" class="DataPoint=OnlineNow;UserID=94243940;" align="center"><img src="http://i.myspace.com/site/images/clear.gif" border="0" height="20" width="80"></div>

</div>

<div class="left w100">

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=7892788&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl09_friendLink">Tiffany</a><br>

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=7892788&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl09_friendImageLink"><img src="http://myspace-613.vo.llnwd.net/01474/31/60/1474470613_s.jpg" alt=""></a><br>

<div id="UserDataNode9" class="DataPoint=OnlineNow;UserID=7892788;" align="center"><img src="http://i.myspace.com/site/images/clear.gif" border="0" height="20" width="80"></div>

</div>

<div class="left w100">

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=80822949&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl10_friendLink">HopeIsEmo.com</a><br>

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=80822949&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl10_friendImageLink"><img src="http://myspace-293.vo.llnwd.net/00824/39/25/824875293_s.jpg" alt=""></a><br>

<div id="UserDataNode10" class="DataPoint=OnlineNow;UserID=80822949;" align="center"><img src="http://i.myspace.com/site/images/clear.gif" border="0" height="20" width="80"></div>

</div>

<div class="left w100">

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=57788321&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl11_friendLink">posh suicide</a><br>

<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=57788321&amp;MyToken=256da639-f26d-4ac0-933d-be20fa5859e8" id="ctl00_Main_ctl00_FriendSpace1_FriendRepeater_ctl11_friendImageLink">

and I need to get just the id numbers like:

80822949

57788321

7892788

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Your going to have to find a way to remove doubles :P

#include <array.au3>
#include <Inet.au3>
Global $counter, $Numbers[42]
$sURL = _INetGetSource("http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=9048423")
$reg = StringRegExp($sURL,"&friendid=(\d+)",3)
_ArrayDisplay($reg,'')
just for a bit of foolproof might wanna change &friendid=(\d+) to [&?]friendid=(\d+)

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

just for a bit of foolproof might wanna change &friendid=(\d+) to [&?]friendid=(\d+)

Thanks, it worked but is there a faster way?

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • Moderators

This may be too simple, but this wouldn't work?

#include <array.au3>
#include <string.au3>
$sString = FileRead('Whatever or use InetGetSource')
$aArray = _StringBetween($sString, 'friendid\=', '\&', -1, 1)
_ArrayDisplay($aArray, '')
(#include <array.au3> and _ArrayDisplay() only used for showing the result)

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

this did work but it just took too long

Global $counter, $Numbers[42]
$sURL = _INetGetSource("http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=9048423")
$reg = StringRegExp($sURL,"[&?]friendid=(\d+)",3)
_ArrayDisplay($reg,'')

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

as i said you must figure out a way to find duplicates haha which i found out to be quite difficult , which just gave me an idea :P , u first take the first string say in a file, do a stringinstr, and then get the length and trim nevermind hahah ive yet to figure a way to get rid of duplicates

LOL its cool. I just wanted to make some Myspace UDFs, friend finder, and messangers

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

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...