High, I'm new to PHP (and all server side scripting), but I was wondering if anyone can help me with this problem:-
I'm using a PHP script developed by MC4.com which is a simple script to grab elements of any other web page on the net. What I want to use it for is to take headline links from other sites and place them in my site - which then link back to the specific articles on the source site. This works fine if the headline links I'm grabbing are absolute links, but will not work from my site if they are relative links.
You could try to match if the grabbed URL includes http:// at the beginning of the url and if not figure out where did you actually grab the url.
If the grabbed url doesn't include the http-header and after you've know what is the site's actual url (like http://www.domain.com), you could try to add them together.
Or in other words:
1. grab url
2. check if url is absolute: if (substr_count($grabbed_url, "http://" == 1) { ... }
3. else if it is not absolute, do $new_absolute_url = $grabbed_domain . $grabbed_url;
Edit: Thou shall not be hasty Perhaps I should read the example code given above more carefully.
Indeed, you just add another variable $GrabDomain (http://www.domain.com), which is part of $GrabURL, check the existance of http://-header in your grabbed url's, if it isn't there, add the grabbed relative url to the $GrabDomain-variable.
<Edited by hmahonen on 11-29-2000 at 07:08 AM>
Bookmarks