Jump to content

Parsing a url for a given string


Nomax5

Recommended Posts

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.

[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 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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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? 
Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.