description like <a href="myexample.com"></a> should return blank
description like <a href=myexample.com></a> should return blank
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to replace url’s from dynamic content, you can do this with regular expressions, or an easier method like using phpQuery which will allow you to use a much method of looking up links within HTML, and replacing their HREF attribute.
I’ve not used phpQuery for a while, but I believe that would do the trick. Also, if the links you are trying to remove are navigation, rss feeds, etc, you can use phpQuery to return only a particular portion of the externalPage, meaning you would no longer have to remove the links that are not within the portion you want.
For example, if you are trying to get an article from the external page that exists within a DIV having an ID of “articleBox”, you could do this:
That would return only that particular element, and the contents within it.
You may find that PHPSimpleHTMLDOMParser is easier to work with. Here’s an example of how to use it against slashdot to scrape parts of the main page: