View Full Version : if($content !~ text rather than link
snoop
08-06-2003, 04:08 AM
currently the below script searches a page for a particular link in this case yahoo.com, and it works ok. but if i want it to check a piece of text from the defined page ($links_page), what do i change it to. thanks in advance
sub check_links_page {
$content = get($links_page);
$content =~ s/\n//g;
$content =~ s/ //g;
if($content !~ /\<a href.+yahoo.com.+/i) {
YUPAPA
08-06-2003, 08:44 AM
sub check_links_page {
$content = get($links_page);
$content =~ s/\n//g;
$content =~ s/\s//g;
if($content !~ /\<A\s*HREF=\"http:\/\/www\.yahoo\.com(.*)\"\s*\>/i || $content !~ /\<A\s*HREF=\"http:\/\/\.yahoo\.com(.*)\"\s*\>/i) {
}
}
According to your code, it is checking for matches that are NOT equal to yahoo. If you want it to check for links equal to yahoo, then replace !~ with =~ :p
snoop
08-06-2003, 11:14 AM
yeh i see what your saying and probably didn't mention that initially, but my question still remains the same. how do i get it to check for text matches as opposed to link matches.
ie. if the page doesn't have this text.... instead of
if the page doesn't have this link....
ACJavascript
08-06-2003, 03:56 PM
How about just doing this
sub check_links_page {
$content = get($links_page);
$content =~ s/\n//g;
$content =~ s/ //g;
if($content =~ /Hi there this is some text/i) {
YUPAPA
08-06-2003, 09:07 PM
Originally posted by snoop
yeh i see what your saying and probably didn't mention that initially, but my question still remains the same. how do i get it to check for text matches as opposed to link matches.
ie. if the page doesn't have this text.... instead of
if the page doesn't have this link....
then it is probably this :)
if($content !~ /the_text/i) {
}
Take out the 'i' (/the_text/i) if you want to be case sensitive
snoop
08-08-2003, 01:41 AM
yeh thanks it worked.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.