Sign in to follow this  
Followers 0
ConsultingJoe

finding an id in a link using StringRegExp?

13 posts in this topic

#1 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

woops i cant read xD hold on

Edited by Thatsgreat2345

Share this post


Link to post
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]

Share this post


Link to post
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,'')

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Thanks, it worked but is there a faster way?

probably not. that's one BIG web page there.

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

Share this post


Link to post
Share on other sites

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)

[center]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.[/center]

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
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]

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  
Followers 0