AutoHotkey Community

It is currently May 27th, 2012, 12:50 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: July 22nd, 2011, 4:34 pm 
Offline

Joined: March 13th, 2008, 1:20 am
Posts: 7
If I have a page open with URL "http://blahblahblah/blahblah/getting+started.html", the script I need should open a new tab with the URL http://(server_name)/getting_started_txt_(random_alphanumeric_code_here).html

Note that there is only one file on the (server_name) server which matches that getting_started_txt part and the rest of the file name can be anything.
Also note that the source URL has + between words and not spaces, underscore.
But the new URL must have
1. + replaced with undercore
2. _txt_ suffixed afterwards
3. ability to pick the first html file that matches getting_started_txt_<random_alphanumeric_code_here>.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2011, 5:07 pm 
SplitPath works to get the parts, which you can reassemble
Code:
var=http://blahblahblah/blahblah/getting+started.html
SplitPath, var, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
MsgBox % OutFileName "`n" OutDir "`n" OutExtension "`n" OutNameNoExt "`n" OutDrive


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2011, 5:16 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
I didn't even know SplitPath worked on URLs :oops:

Here's a way to get the path from the html.

Code:
#include <RegEx>
Needle := RegEx.Literal("http://") . ".*?" . RegEx.Literal("/getting+started.html")
Msgbox % RegEx.MatchSimple(HTML, "", Needle)


It requires this library and a recent AutoHotkey_L. You can make it work with other versions using RegExMatch if you want.
RegEx Class

And one really important question... what browser are you using?

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, jrav, MSN [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group