I want to create check

Discussion in 'PHP' started by khawar latif, May 12, 2012.

  1. #1
    I want to create check for url extensions.
    for example

    if http://link/kk.mp3

    {
    save on file

    }

    if http://link/html, php and other links

    {
    open link and start finding .mp3
    }
     
    khawar latif, May 12, 2012 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    
    <?
    $file = "http://..../index.html";
    $exp = explode(".", $file);
    
    $extension = strtolower(end($exp));
    
    if($extension == "html") {
    
    }
    ...
    ?>
    
    PHP:
     
    Oli3L, May 12, 2012 IP
    khawar latif likes this.
  3. khawar latif

    khawar latif Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php

    $original_file = file_get_contents ("http://papa.pk/indian/s12/Rakhtbeej/Songs.html");

    $stripped_file = strip_tags($original_file, "<a>");

    preg_match_all("/<a(?:[^>]*)href=\"([^\"]*)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);



    header("Content-type: text/plain"); //Set the content type to plain text so the print below is easy to read!

    $str=print_r($matches); //View the array to see if it worked


    ?>
    run this script and see i want to crawl all link instead of .mp3 .mp3 links save on txt
     
    Last edited: May 12, 2012
    khawar latif, May 12, 2012 IP
  4. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #4
    
    <?php
    
    $original_file = file_get_contents ("http://papa.pk/indian/s12/Rakhtbeej/Songs.html");
    
    $stripped_file = strip_tags($original_file, "<a>");
    
    preg_match_all("/<a(?:[^>]*)href=\"([^\"]*mp3)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);
    
    
    
    header("Content-type: text/plain"); //Set the type to plain text so the print below is easy to read!
    
    $str=print_r($matches); //View the array to see if it worked
    
    
    ?>
    
    PHP:
     
    Oli3L, May 12, 2012 IP
  5. khawar latif

    khawar latif Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oli3L you copy same my code lol please update it
     
    khawar latif, May 12, 2012 IP
  6. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #6
    i edited it so you'd get the links on $matches[1] ...
     
    Oli3L, May 12, 2012 IP
  7. khawar latif

    khawar latif Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    it's just finding .mp3 i need .mp3 but other links for depth crawl for example if http:// link.html have 2 .mp3 links and 3 .html crawl save mp3 link on txt and start crawling .html and other follow links
     
    khawar latif, May 12, 2012 IP