Ejemplo n.º 1
0
function getArticle($link, $title, $filestr)
{
    $contents = file_get_contents($link);
    $doc = new DOMDocument();
    $doc->loadHTML($contents);
    $content2 = $doc->getElementById('content2');
    //去除Content中多余元素(table)
    if (is_null($content2)) {
        return;
    }
    $tablesInContent = $content2->getElementsByTagName('table');
    foreach ($tablesInContent as $t) {
        $content2->removeChild($t);
    }
    $imgurl = "";
    $imgsInContent = $content2->getElementsByTagName('img');
    foreach ($imgsInContent as $img) {
        $imgurl = $img->getAttribute('src');
        break;
    }
    $table = $content2->parentNode->parentNode;
    $aTopic = $table->childNodes->item(2);
    $topicName = trim($aTopic->childNodes->item(0)->textContent);
    $topicLocal = "other";
    $topicID = 0;
    $result = mysql_query('select id,local,name from vatican_topic where name="' . $topicName . '"');
    while ($row = mysql_fetch_array($result)) {
        $topicLocal = $row['local'];
        $topicID = (int) $row['id'];
    }
    $fp = fopen($filestr, "w");
    if (!$fp) {
        echo $filestr;
        return;
    } else {
        $content = '<html><head><title>' . $title . '</title><meta http-equiv=Content-Type content="text/html;charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="format-detection" content="telephone=no"><link href="../articles.css" type="text/css" rel="stylesheet"></head><body><div class="topic"><span class="current"><a href="/">首页</a> › <a href="../index.php">普世教会</a> › <a href="../index.php?topic=' . $topicID . '">' . $topicName . '</a></span><h1 class="topic-title">' . $title . '</h1></div><div class="content">' . get_inner_html($content2) . '</div><br/><br/><a class="src" href="' . $link . '">>>>原始文章</a></body><script type="text/javascript" language="javascript" src="/include/googleanalysis.js"></script><script type="text/javascript" language="javascript" src="http://cathassist.org/include/common.js"></script><script type="text/javascript">document.addEventListener("DOMContentLoaded", function(){SetWechatShare("' . $title . '","' . ROOT_WEB_URL . 'vaticanacn/' . $filestr . '","' . $imgurl . '","' . $title . '");});</script></html>';
        fwrite($fp, $content);
        $result = mysql_query('insert into vaticanacn (title,src,local,time,cate,picurl) values ' . '("' . mysql_real_escape_string($title) . '","' . mysql_real_escape_string($link) . '","' . mysql_real_escape_string($filestr) . '",curdate(),' . $topicID . ',"' . mysql_real_escape_string($imgurl) . '");');
    }
    fclose($fp);
}
Ejemplo n.º 2
0
function ripMemes()
{
    for ($page = 1; $page <= 9; $page++) {
        $memeFetch = curl_init('http://memegenerator.net/memes/popular/alltime/page/' . $page);
        curl_setopt($memeFetch, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($memeFetch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($memeFetch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($memeFetch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($memeFetch);
        $dom = new DOMDocument();
        $dom->loadHTML($result);
        $finder = new DomXPath($dom);
        $elements = $finder->query("/html/body//ul[@class='horizontal gallery  ']/li");
        echo '<pre>';
        if (!is_null($elements)) {
            /** @var \DOMElement $element */
            foreach ($elements as $element) {
                //var_dump(get_inner_html($element));die;
                //<a href="\/([\w-]+)"> //NAME
                //http:\/\/cdn.meme.am\/images\/\d+x\d+\/([^\.]+) //imageID
                //data-entity-name="Generator" data-entity-id="([^"]+) //generatorID
                $html = get_inner_html($element);
                $name = '';
                if (preg_match('/<a href="\\/([\\w-]+)">/', $html, $matches)) {
                    $name = $matches[1];
                }
                echo '\'' . str_replace('-', ' ', $name) . '\' => [' . PHP_EOL;
                echo '\'name\' => \'' . $name . '\',' . PHP_EOL;
                if (preg_match('/data-entity-name="Generator" data-entity-id="([^"]+)/', $html, $matches)) {
                    echo '\'id\' => \'' . $matches[1] . '\',' . PHP_EOL;
                }
                if (preg_match('/http:\\/\\/cdn.meme.am\\/images\\/\\d+x\\d+\\/([^\\.]+)/', $html, $matches)) {
                    echo '\'imageId\' => \'' . $matches[1] . '\',' . PHP_EOL;
                }
                echo '],' . PHP_EOL;
            }
        }
    }
}
Ejemplo n.º 3
0
    echo "<h1>" . $termin_name . "</h1>";
    // get ad image, um Image rauszuziehen
    $termin_image_tag = $xpath->query("//img/@src");
    $termin_image = $termin_image_tag->item(0)->nodeValue;
    echo "<p><img src='http://kino-wolfhagen.de" . $termin_image . "'>";
    // Get Location
    $termin_location_tag = $xpath->query("//div[@class='program-col-text']");
    $termin_location = trim($termin_location_tag->item(0)->nodeValue);
    echo $termin_location . "</p>";
    echo "</header>";
    echo "<section>";
    echo "<div style='clear:both;'></div>";
    echo "<h2>Zeiten</h2>";
    // Get Date
    $termin_date_tag = $xpath->query("//div[@class='program-table movie-program']");
    $termin_date = get_inner_html($termin_date_tag->item(0));
    echo "<div>" . $termin_date . "</div>";
    echo "</section>";
    echo "</article>";
}
?>
                <aside>
                    <h3>aside</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sodales urna non odio egestas tempor. Nunc vel vehicula ante. Etiam bibendum iaculis libero, eget molestie nisl pharetra in. In semper consequat est, eu porta velit mollis nec. Curabitur posuere enim eget turpis feugiat tempor. Etiam ullamcorper lorem dapibus velit suscipit ultrices.</p>
                </aside>

            </div> <!-- #main -->
        </div> <!-- #main-container -->

        <div class="footer-container">
            <footer class="wrapper">