1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress Tags grabber

Discussion in 'General Programming Chat' started by Boxic, Jan 27, 2009.

  1. Boxic

    Boxic Newbie

    Dec 20, 2008
    Likes Received:
    Not sure what you could use this for, i used it just to bloat some pages out with keywords.

    It grabs what wordpress . com considers to be "hot topics" via h t t p : / / wordpress . com /tags/

    (Sorry i can not post links yet)

    $wp_page = file_get_contents(trim("h t t p : / / w ordpress . com/tags/"));
    $regex = '#<p class="heatmap"[^>]*>(.*?)</p[^>]*>#is';
    echo "<pre>";
    //var_dump( $wp_page_1 );
    echo "</pre>";
    $regex = '#(<a href=\'(.*?)>)(.*?)(</a[^>]*>)#is';
    echo "<pre>";
    //var_dump( $wp_page_2[3] );
    echo "</pre>";
    foreach ($wp_page_2[3] as $tag)
            $font_size = rand(10, 25) . "." . rand(1, 99);
            $wp_tag_cloud .= "<a href='javascript:cloudsearch(\"". $tag ."\");' style='font-size: ". $font_size . "px;' title='". $tag ."'>".$tag."</a> \n";
    echo $wp_tag_cloud;
    $fp = fopen('tagcloud.txt', 'w');
    fwrite($fp, $wp_tag_cloud);
    I just used rand() to make my own font sizes just to make it look a bit "better" for what i needed, but you can do what you like with it $tag within the foreach loop is all you need to work with. This example dumps my fake cloudsearch url to tagcloud.txt