Nomax5 Posted September 2, 2006 Share Posted September 2, 2006 What is the most efficient way to parse a submitted url for a given stringI was thinking something along these lines but I’m not familiar with this sort of thing.[code]$website = "http://www.justasign.com";$clue="Sale sign displaying"$secret_word="your";fopen($website, "r");strstr[/code]but then I got to thinking about buffer and timeout and thought I'll ask the experts..[b]Background and why[/b]I have this new website, it’s a lottery for websites where you win traffic as the prizeIt works like this:To enter the lottery you have to visit todays winning website and find the secret word using the clue:Then you enter Todays secret word found on the winning webpage Your website A secret word from your content And a clue (the 3 words before your secret word)If you win then tomorrow everyone has to visit your website to find the secret word.I am manually checking each entry for the clue and the secret word but I need to automate it somehow. I’d like to run the code if fast enough at the point someone enters their website so I can error message themIf not I could loop through the entries and check them all prior to running the lottery. Any help greatly appreciatedRoy Quote Link to comment https://forums.phpfreaks.com/topic/19476-parsing-a-url-for-a-given-string/ Share on other sites More sharing options...
redarrow Posted September 2, 2006 Share Posted September 2, 2006 Sorry to down harted but this is classed as a advanced topic.i have inclueded how you get to match urls below and you should be able to work it out your self.good luck.remember that you have to crawl before you walk.[code]//<?php //$your_link="http://www.what_ever.co.uk";//$remote_url="http://www.what_ever.php";//$match_pattern = preg_quote(rtrim($your_link, "/"), "/"); //if ($handle = @fopen($remote_url, "r")) { //while (!feof($handle)) { //$part = fread($handle, 1024); //if (preg_match("/<a(.*)href=[\"']".$match_pattern. //"(\/?)[\"'](.*)>(.*)<\/a>/", $part)) { //echo "links there"; //}// }//fclose($handle); //} else{//echo" no link sorry";//}//?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19476-parsing-a-url-for-a-given-string/#findComment-84618 Share on other sites More sharing options...
Nomax5 Posted September 2, 2006 Author Share Posted September 2, 2006 I don’t think I explained it very clearlyIf I had a url say “http://www.whatever.com/article.html” and I wanted to know if the word “Fish” was in that webpage’s contentnot the url name itself but the content on the page the url is pointing to.Or am I missing the point? Quote Link to comment https://forums.phpfreaks.com/topic/19476-parsing-a-url-for-a-given-string/#findComment-84672 Share on other sites More sharing options...
redarrow Posted September 2, 2006 Share Posted September 2, 2006 i only managed to get a match from websites and sub url's i got no idear how to get a specific word fron another persons website.sorry i tried that and really had a 14 hour go last week and no one could help me on here so i gave up.hope you get it good luck. Quote Link to comment https://forums.phpfreaks.com/topic/19476-parsing-a-url-for-a-given-string/#findComment-84677 Share on other sites More sharing options...
Nomax5 Posted September 11, 2006 Author Share Posted September 11, 2006 thanks for looking anyways redarrow I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/19476-parsing-a-url-for-a-given-string/#findComment-90017 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.