Medic873 Posted August 27, 2010 Share Posted August 27, 2010 Okay I alwys have trouble doing things like this. I am trying to pull the first name under the variable $FirstName And the second name under the variable $Lastname This url always just loads a new name so I always have random names http://www.behindthename.com/random/random.php?number=2&gender=m&surname=&all=yes But I cant seem to accuratly pull them pleaes help thank you Link to comment Share on other sites More sharing options...
wakillon Posted August 27, 2010 Share Posted August 27, 2010 (edited) $_NameArray = StringSplit ( 'Eadwig kresimir", ' ' ) ; use a space as delimiter $FirstName = $_NameArray[1] $Lastname =$_NameArray[2] That's good for you ? Edited August 27, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Medic873 Posted August 27, 2010 Author Share Posted August 27, 2010 I was looking to copy somthing like this $vLoremText = _StringBetween(_INetGetSource('http://lipsum.com/feed/html'), '<div id="lipsum">', '</div>') MsgBox(0, "", StringReplace(StringReplace($vLoremText[0], '</p>', ''), '<p>', '')) but I dont really understand how to Link to comment Share on other sites More sharing options...
Medic873 Posted August 30, 2010 Author Share Posted August 30, 2010 can anyone help me with this Link to comment Share on other sites More sharing options...
Varian Posted August 30, 2010 Share Posted August 30, 2010 From the website you listed, this works for me: #include <string.au3> #include <INet.au3> $Source = _INetGetSource('http://www.behindthename.com/random/random.php?number=2&gender=m&surname=&all=yes') $Name = _StringBetween($Source, '<a href="/name/', '</a> </font></center><br><br><br>') If @error Then Exit $FullName = _StringProper(StringRegExpReplace($Name[0], '" class="plain">.*</a> <a href="/name/.*" class="plain">', ' ')) Msgbox(32, 'Extracted Name', $FullName) Link to comment Share on other sites More sharing options...
Medic873 Posted August 30, 2010 Author Share Posted August 30, 2010 OMG it works thank you so much I was trying so many diffrent things im going analyze how you did it and see If I cant figure it out for my self and future reference. Although If you could help me how can I now divide the variable $FullName into two variable I image the best way to do this is by saying anything in front of the first space = $Firstname Anything after space is $Lastname How do I do this I can only find things to divide a string by its length not spaces. Link to comment Share on other sites More sharing options...
Varian Posted August 30, 2010 Share Posted August 30, 2010 (edited) You can use StringSplit or _StringBetween or even StringRegExpReplace...here is an example with _StringBetween #include <string.au3> #include <INet.au3> $Source = _INetGetSource('http://www.behindthename.com/random/random.php?number=2&gender=m&surname=&all=yes') $Name = _StringBetween($Source, '<a href="/name/', '</a> </font></center><br><br><br>') If @error Then Exit $FullName = _StringProper(StringRegExpReplace($Name[0], '" class="plain">.*</a> <a href="/name/.*" class="plain">', ' ')) $Firstname = _StringBetween($FullName, '', ' ') $Lastname = _StringBetween($FullName, ' ', '') Msgbox(32, 'Extracted Name', 'Full Name = ' & $FullName & @LF & 'First Name = ' & $Firstname[0] & @LF & 'Last Name = ' & $Lastname[0]) Let me know if you need me to add comments to explain what is going on in the script Edited August 30, 2010 by Varian 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