I am trying to check whether a particular URL is present in a page supplied by another website.
I need to check whether or not the given URL contains a link to my website.
I am using PHP, and I would like to use preg.
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 know the url you are looking for, can’t you use
strpos()?This is a simple match – but it doesn’t tell you whether it’s a hyperlink – just if the url is somwehere in the page. If you want to verify is actually a hyperlink than this approach or a simple regex is not going to help (at least a regex is likely to be fiddly and unreliable). You need to parse the DOM properly, extract out the
<a>elements and check against the href attribute.