Jump to content


Photo

Parsing a url for a given string


  • Please log in to reply
4 replies to this topic

#1 Nomax5

Nomax5
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationYork England

Posted 02 September 2006 - 02:40 PM

What is the most efficient way to parse a submitted url for a given string

I was thinking something along these lines but I’m not familiar with this sort of thing.

$website = "http://www.justasign.com";
$clue="Sale sign displaying"
$secret_word="your";

fopen($website, "r");
strstr

but then I got to thinking about buffer and timeout and thought I'll ask the experts..

Background and why

I have this new website, it’s a lottery for websites where you win traffic as the prize

It 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 them

If not I could loop through the entries and check them all prior to running the lottery.

Any help greatly appreciated

Roy


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 03:52 PM

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.




//<?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";

//}

//?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Nomax5

Nomax5
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationYork England

Posted 02 September 2006 - 05:33 PM

I don’t think I explained it very clearly

If 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 content

not the url name itself but the content on the page the url is pointing to.

Or am I missing the point? 


#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 September 2006 - 05:40 PM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Nomax5

Nomax5
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationYork England

Posted 11 September 2006 - 09:04 PM

thanks for looking anyways redarrow I appreciate it.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users