Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with regular expression for relative addresses

Status
Not open for further replies.

dimitad

Programmer
Joined
Sep 16, 2006
Messages
10
Location
US
Hi all,

I have searched for this a lot but with no success. There is a module called LinkExtor which automatically extracts links contained in a web page within tags like "a href" and "src". However, this is not complete since links can be present in other places on a webpage (e.g. javascript) so now i am looking for a module or regular expression that would match any links on a page regardless of their location.

Thanks!
 
I'm sorry, I'm not sure I know what you mean by this ?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Ok,

Lets say you have a link on your page called "something.php". The currently available modules will try to locate this link with regular expressions that match tags like: <a href, <img src=, <form action=, and so on. So, if the link "something.php" is contained within one of those tags it will be processed. However, you might have javascript that says:
window.open = ("something.php" ...
or
location.href = ("something.php"

Those along with other cases do not get matched so I was looking for a regular expression that would match all extensions (.php, .asp, .html, .php3, .php4, .pl etc) within a web page assuming you have access to the actual file and not just the static page source.
 
Your script could call Javascript code, assign the output to a variable, and then parse the variable for the links you seek

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Hmmm,
sorry but does Javascript have better support for parsing links from a given file?
 
You could write your own ;-)

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top