Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    Question Reading Remote Page Data??

    Hi,
    I found this script on http://ca3.php.net/get_meta_tags,

    But i'm having trouble making it working,

    PHP Code:

    $title 
    "";
    if (
    $fp = @fopen($_REQUEST['url'], 'r' )) {

        
    $cont "";

        
    // read the contents
        
    while( !feof$fp ) ) {
        
    $buf trim(fgets$fp4096 )) ;
        
    $cont .= $buf;
        }

        
    // get tag contents
        
    @preg_match"/<title>([a-z 0-9]*)<\/title>/si"$cont$match );

        
    // tag contents
        
    $title strip_tags(@$match]);
        echo 
    $title;
        } 
    it doesn't seem to bring back any data,

    anyone have any ideas why this is not working?

    thanks in advance for your time!
    -Ken

  • #2
    New Coder
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try using fsockopen()

  • #3
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,088
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Change this statement:

    Code:
    @preg_match( "/<title>([a-z 0-9]*)<\/title>/si", $cont, $match );
    to this:

    Code:
    @preg_match("|<title>(.*)</title>|s", $cont, $match );
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    There is nothing wrong with your code , works fine for me as-is

    2 possibles,

    1) you do not have fopen wrappers enabled in your php.ini
    2) the page you are trying to parse simply does not allow these types of remote requests
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    thanks vinyl-junkie!
    that fixed it;-)

    -Ken

  • #6
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah ok,
    found one little problem,

    I've found that alot of pages seem to have the title in CAPS, not sure if this is something done by the software used to make the pages or not,

    but is there anyway to make this line read both upper and lower case titles?

    @preg_match("|<TITLE>(.*)</TITLE>|s", $cont, $match );

    @preg_match("|<title>(.*)</title>|s", $cont, $match );


    thanks again for your time!
    -Ken

  • #7
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    @preg_match("|<title>(.*)</title>|si", $cont, $match );
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #8
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah, simple as at;-)

    thanks!

    -Ken


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •