Jump to content

[SOLVED] Scan a URL and pull values


lip9000

Recommended Posts

Hey guys, just wondering how would I go about creating a script that scans a url's source code and brings back data contained within certain regions of that page.

 

For example how would I get it to bring back the information contained within the sites title tags, and bring back information contained within a certain field on that page.

 

So the script would be to enter a url, then it scans that page, gets the values located in the spots we want like the title and such, and then brings it back to the page in variables so we can then insert it into a database.

 

Thanks in advance :D

Link to comment
Share on other sites

doesn't seem to work. what am i doing wrong?

 

$str = readfile('http://youtube.com/watch?v=7pVmmsuuc5U');

$title = eregi_replace("<title>([a-zA-Z0-9[:punct:][:space:]]+)</title>", "\\1", $str);

echo $title;

 

 

so basically i want it to return the title of the youtube page

Link to comment
Share on other sites

Sorry to be annoying, but the code just displays the youtube page, and doesn't echo out the title?? My code is:

 

$str = print readfile('http://youtube.com/watch?v=7pVmmsuuc5U');

$begin = strpos($str, "<title>");
$end = strpos($str, "</title>");
$title = substr($str, $begin+7, $end);


echo $title;

 

what's going on? Just displaying the url, no echoed title.

 

 

Link to comment
Share on other sites

$str = readfile('http://youtube.com/watch?v=7pVmmsuuc5U');

$begin = strpos($str, "<title>");
$end = strpos($str, "</title>");
$title = substr($str, $begin+7, $end);


echo $title;

 

No print before readfile still displays the whole youtube page, and still does not echo out the title!

 

I'm testing locally on WAMP, does it need to be tested live?? Or is there still something wrong with the code?

Link to comment
Share on other sites

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.