当前位置: 首页>>代码示例>>PHP>>正文


PHP simple_html_dom::load_file方法代码示例

本文整理汇总了PHP中simple_html_dom::load_file方法的典型用法代码示例。如果您正苦于以下问题:PHP simple_html_dom::load_file方法的具体用法?PHP simple_html_dom::load_file怎么用?PHP simple_html_dom::load_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simple_html_dom的用法示例。


在下文中一共展示了simple_html_dom::load_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_next_page_url

function get_next_page_url($url)
{
    $html = new simple_html_dom();
    $html->load_file($url);
    $next_page = $html->find('.next_page');
    $next_page_link = null;
    foreach ($next_page as $next_page_link) {
        $next_page_link = $next_page_link->href;
    }
    return 'https://www.goodreads.com' . $next_page_link;
}
开发者ID:vossavant,项目名称:phoenix,代码行数:11,代码来源:scrape-quotes-from-goodreads.php

示例2: initCategoryParser

 public function initCategoryParser($link)
 {
     $this->_category_link = $link;
     $html = new simple_html_dom();
     $link = $this->_domain . $link;
     $html->load_file($link);
     $this->_counter++;
     if ($this->_endOfLink($html) || $this->_counter > $this->_pages_to_get) {
         return array('last_link' => $this->_category_link, 'links' => $this->_links, 'parsing_data' => $this->_new_parsing_date);
     } else {
         $this->_parseHtml($html);
     }
     return array('last_link' => $this->_category_link, 'links' => $this->_links, 'parsing_data' => $this->_new_parsing_date);
 }
开发者ID:cristidev,项目名称:ilaw,代码行数:14,代码来源:ilawCategoryParser.php

示例3: getDetail

 function getDetail($url)
 {
     Yii::import('ext.simple_html_dom');
     $html = new simple_html_dom();
     // $context = stream_context_create($this->user_agent);
     // $html->load_file($url, false, $context);
     $html->load_file($url);
     $db = $html->find('table td[class=bor f2 db]', 0);
     if (isset($db->plaintext)) {
         return substr($db->plaintext, strlen($db->plaintext) - 2);
     } else {
         return 0;
     }
 }
开发者ID:bangnguyen47,项目名称:xoso,代码行数:14,代码来源:CrawlCommand.php

示例4: getdata

 public function getdata()
 {
     //echo"shreejana";die;
     set_time_limit(0);
     include 'simple_html_dom.php';
     $target_url = 'Nepal Rastra Bank.htm';
     $html = new simple_html_dom();
     $html->load_file($target_url);
     $table = $html->find('/html/body/table[2]/tbody/tr[2]/td[2]/table[2]/tbody');
     $table = $table[0];
     $i = 0;
     //increment array
     foreach ($table->find('tr') as $row) {
         $date = $row->find('td[1]');
         $date = $date[0]->plaintext;
         if (preg_match("/[0-9]+[-][0-9]+[-][0-9]+/", $date)) {
             $j = 1;
             //increment values
             foreach ($table->find('tr[1]/td') as $head) {
                 $currency = trim($head->plaintext);
                 if ($currency == "Swedish Kr." || $currency == "Danish Kr." || $currency == "HKG\$") {
                     $rates[$i]['date'] = $date;
                     $rates[$i]['curname'] = $currency;
                     $rate = $row->find('td[' . $j . ']');
                     $rate = trim($rate[0]->plaintext);
                     $rates[$i]['buyingrate'] = $rate;
                     $rates[$i]['sellingrate'] = null;
                     $j++;
                     $i++;
                 } elseif ($currency == "Date") {
                     $j++;
                 } else {
                     $rates[$i]['date'] = $date;
                     $rates[$i]['curname'] = $currency;
                     $rate = $row->find('td[' . $j . ']');
                     $rate = trim($rate[0]->plaintext);
                     $rates[$i]['buyingrate'] = $rate;
                     $j++;
                     $rate = $row->find('td[' . $j . ']');
                     $rate = trim($rate[0]->plaintext);
                     $rates[$i]['sellingrate'] = $rate;
                     $j++;
                     $i++;
                 }
             }
         }
     }
     var_dump($rates);
 }
开发者ID:pshreez,项目名称:PHP,代码行数:49,代码来源:loadfile.php

示例5: insert_urls

function insert_urls($conn)
{
    $target_url = $_POST['t_url'];
    // t_url is taken from user input through the text box
    $html = new simple_html_dom();
    if (!$html->load_file($target_url)) {
        $i = 1;
        foreach ($html->find('img') as $image) {
            $image_url = $image->src;
            $pp_image = imagecreatefromstring(file_get_contents($image_url));
            imagejpeg($pp_image, 'temp_images/img' . $i . '.jpeg');
            // Saves the image as a jpeg file
            $detector = new svay\FaceDetector('detection.dat');
            if ($detector->faceDetect('temp_images/img' . $i . '.jpeg')) {
                // If the detector detects a face
                $sql = "INSERT INTO images (url) VALUES ('{$image_url}')";
                // Insert that url into the database
                $stmt = $conn->prepare($sql);
                $stmt->execute();
            }
            $i++;
        }
    } else {
        echo '<br /><div id="strongtext"><p><strong>Palun sisesta mõni muu aadress.</strong></p></div>';
        var_dump($html->load_file($target_url));
    }
    $temp_files = glob('temp_images/*');
    // After the foreach loop is done checking all of the images
    foreach ($temp_files as $temp_file) {
        if (is_file($temp_file)) {
            unlink($temp_file);
        }
    }
    echo '<script>alertFunction();</script>';
    // Alert the user that the script has finished working
}
开发者ID:rontonnison,项目名称:rakendus,代码行数:36,代码来源:db.php

示例6: getArticleFromUrl

 public function getArticleFromUrl($url)
 {
     $url = $this->_domain . trim($url, '/');
     $this->_url = $url;
     $this->_url_hash = md5($url);
     $this->_articles[$this->_url_hash] = array('url' => $url);
     $article_html = new simple_html_dom();
     $article_html->load_file($url);
     if (is_null($article_html)) {
         return;
     }
     $this->_article_html = $article_html;
     $this->_getMetaFromArticle();
     $this->_getCategoryFromArticle();
     $this->_getArticle();
     return $this->_articles;
     echo '<pre>';
     print_r($this->_articles);
     echo '</pre>';
 }
开发者ID:cristidev,项目名称:ilaw,代码行数:20,代码来源:ilawParser.php

示例7: getChanges

function getChanges($job, $project)
{
    $commitblacklist = array('Merge branch', 'Merge pull', 'Revert', 'Cleanup');
    $url = "http://ci.earth2me.net/viewLog.html?buildId={$job}&tab=buildChangesDiv&buildTypeId={$project}&guest=1";
    $html = new simple_html_dom();
    $html->load_file($url);
    $output = "Change Log:<ul>";
    foreach ($html->find('.changelist') as $list) {
        foreach ($list->find('.comment') as $comment) {
            $text = $comment->innertext;
            foreach ($commitblacklist as $matchtext) {
                if (stripos($text, $matchtext) !== FALSE) {
                    $text = "";
                }
            }
            if ($text != "") {
                $output .= "<li>{$text}</li>\n";
            }
        }
    }
    $output .= "</ul>";
    file_put_contents('status.log', "Collected changes! ", FILE_APPEND);
    return $output;
}
开发者ID:SavnithFreedom,项目名称:SF-Essentials,代码行数:24,代码来源:upload.php

示例8:

<?php

//Author: Zakaria Hmaidouch
//Website: zhma.info
//Import simplehtmldom lib, from http://simplehtmldom.sourceforge.net
require 'libs/simple_html_dom.php';
$file = 'data.html';
$html = new simple_html_dom();
// Taget URL
$url = 'http://www.zhma.info';
$counter = 1;
$html->load_file($url);
// Data to target
$titles = $html->find('div[class=portfolio-item] h5');
// Open the file to get existing content
$current = @file_get_contents($file);
$current = '<html>
				<head>
					<title>Data Scraping</title>
				</head>
				<body>';
foreach ($titles as $title) {
    // Append a new data to the file
    $current .= "<b>Project {$counter}:</b> {$title->innertext}<br>";
    // Write the contents back to the file
    file_put_contents($file, $current);
    $counter++;
}
$current .= '</body>
			</html>';
开发者ID:Zahma,项目名称:Data_scraping,代码行数:30,代码来源:scraping.php

示例9: foreach

<?php

include 'simple_html_dom.php';
$html = new simple_html_dom();
$content = $html->load_file('IAC.html');
$ret = $html->find('tr');
$fullInfo = [];
$currentOrigin = '';
$currentDestination = '';
foreach ($ret as $line) {
    if ($line->class == 'destination') {
        $link = $line->find('a');
        foreach ($link as $curLink) {
            $currentDestination = $curLink->innertext;
        }
    }
    if ($line->class == 'important origin') {
        $link = $line->find('a');
        foreach ($link as $curLink) {
            $currentOrigin = $curLink->innertext;
        }
    }
    if ($line->class == 'line even') {
        // new flight
        $flightInfo = ['origin' => $currentOrigin, 'destination' => $currentDestination];
        foreach ($line->children as $child) {
            $flightInfo[$child->attr['class']] = $child->plaintext;
        }
        $temp = [];
        foreach ($flightInfo as $key => $value) {
            if (in_array($key, ['remarks', 'valid'])) {
开发者ID:jl0renzen,项目名称:airliner-webui,代码行数:31,代码来源:index.php

示例10:

<?php

# create and load the HTML
include 'simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('http://open.live.bbc.co.uk/weather/feeds/en/918702/3dayforecast.rss');
# get an element representing the second paragraph
$element = $html->find('description');
# output it!
echo "<rss>\n<channel>\n<title>Bluefin Mobile - SA News</title>\n<item>\n<title>SA News</title>\n<description>";
echo $element[1];
echo "</description>\n</item>\n</channel>\n<head/>\n</rss>";
开发者ID:BlueTronTechnologies,项目名称:BFMFeeds,代码行数:12,代码来源:chipata.php

示例11:

<?php

# create and load the HTML
include 'simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('http://astrology.horoscope.com/horoscope/dailyhoroscope/tomorrow-career-horoscope.aspx?sign=2');
# get an element representing the second paragraph
$element = $html->find('div[class=fontdef1]');
# output it!
echo "<rss>\n<channel>\n<title>Bluefin Mobile - Career Horoscopes Taurus</title>\n<item>\n<title>Career Horoscopes Taurus</title>\n<description>";
echo $element[0]->innertext;
echo "</description>\n</item>\n</channel>\n<head/>\n</rss>";
开发者ID:BlueTronTechnologies,项目名称:BFMFeeds,代码行数:12,代码来源:taurus.php

示例12: count

header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
ini_set("user_agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21");
ini_set("max_execution_time", 0);
ini_set("memory_limit", "10000M");
ini_set('display_errors', '1');
$currenturl = "";
$isposted = false;
if (!empty($_POST)) {
    $currenturl = $_POST['url'];
    $isposted = true;
}
if ($isposted) {
    include 'simple_html_dom.php';
    $htmldom = new simple_html_dom();
    $htmldom->load_file($currenturl);
    $title = $htmldom->find('title');
    echo nl2br('{ "page" : ');
    echo nl2br('{ "title" : "' . utf8_encode(trim($title[0]->innertext)) . '",');
    $images = $htmldom->find("img");
    $bodyitems = $htmldom->find("body p text");
    $paragraphs = $bodyitems;
    echo nl2br('"images" : [');
    $numImages = count($images);
    $icount = 0;
    foreach ($images as $image) {
        if ($icount + 1 == $numImages) {
            $cditem = "";
        } else {
            $cditem = ",";
        }
开发者ID:ryanlane,项目名称:LinkGrab-O-Matic,代码行数:31,代码来源:linkgrab.php

示例13: foreach

<?php

// example of how to use advanced selector features
include './lib/simple_html_dom/simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('./search.html');
$classg = $html->find('div[class=g]');
foreach ($classg as $g) {
    foreach ($g->find('a[class=fl]') as $flclass) {
        $flclass->outertext = "";
    }
    echo $g->outertext;
}
$html->clear();
开发者ID:thewintersun,项目名称:google8cn,代码行数:14,代码来源:testdom.php

示例14: str_replace

<?php

# create and load the HTML
include 'simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('https://www.nationallottery.co.za/powerball_home/results.asp?type=1');
# get an element representing the second paragraph
$element = $html->find('span[class=onGreenBackground]');
$element2 = $html->find('img');
$element3 = $html->find('td');
# output it!
echo "<rss>\n<channel>\n<title>Bluefin Mobile - Powerball Results</title>\n<item>\n<title>Powerball Results</title>\n<description>";
echo "The winning Powerball numbers for ";
echo $element[0]->innertext;
echo " are ";
$number1 = str_replace("<img src=\"../images/power_balls/ball_", "", $element2[20]);
echo str_replace(".gif\" width=\"34\" height=\"40\" />", "", $number1);
echo ", ";
$number2 = str_replace("<img src=\"../images/power_balls/ball_", "", $element2[21]);
echo str_replace(".gif\" width=\"34\" height=\"40\" />", "", $number2);
echo ", ";
$number3 = str_replace("<img src=\"../images/power_balls/ball_", "", $element2[22]);
echo str_replace(".gif\" width=\"34\" height=\"40\" />", "", $number3);
echo ", ";
$number4 = str_replace("<img src=\"../images/power_balls/ball_", "", $element2[23]);
echo str_replace(".gif\" width=\"34\" height=\"40\" />", "", $number4);
echo ", ";
$number5 = str_replace("<img src=\"../images/power_balls/ball_", "", $element2[24]);
echo str_replace(".gif\" width=\"34\" height=\"40\" />", "", $number5);
echo ", powerball: ";
$number6 = str_replace("<img src=\"../images/power_balls/power_", "", $element2[25]);
开发者ID:BlueTronTechnologies,项目名称:BFMFeeds,代码行数:31,代码来源:powerball.php

示例15: strripos

 $idCidPoli = str_replace('onPesquisaClick(this, ', '', $cidade->onclick);
 $idCidPoli = str_replace(',', '', $idCidPoli);
 $idCidPoli = str_replace('"', '', $idCidPoli);
 $idCidPoli = str_replace('\'', '', $idCidPoli);
 $idCidPoli = str_replace(');', '', $idCidPoli);
 //guarda a posição do espaço que separa o id do prefeito ou vereador do id do municipio
 $espaco = strripos($idCidPoli, ' ');
 //guarda o id do prefeito ou do vereador que é 11 ou 13
 $codigoCargo = substr($idCidPoli, 0, $espaco);
 //guarda o id da cidade
 $codigoMunicipio = substr($idCidPoli, $espaco + 1);
 //modifica a url do ajax que é exibida na tela
 $urlAjaxPrefeitoVereador = "http://divulgacand2012.tse.jus.br/divulgacand2012/pesquisarCandidato.action?siglaUFSelecionada=" . $siglaUF . "&codigoMunicipio=" . $codigoMunicipio . "&codigoCargo=" . $codigoCargo . "&codigoSituacao=0";
 $htmlCidade = new simple_html_dom();
 //carrega o html que possui todos prefeitos ou vereadores da cidade
 $htmlCidade->load_file($urlAjaxPrefeitoVereador);
 //pega os input com o id e a ultima atualização do politico
 $candidato = $htmlCidade->find('tr[class="odd gradeX"] input');
 $htmlCidade->clear();
 unset($htmlCidade);
 //array para guardar ids dos candidatos e ids da ultima atualização do candidato
 $array = array("sqCandidato", "dtUltimaAtualizacao");
 $i = 0;
 $j = 0;
 foreach ($candidato as $elemento) {
     if (strcmp($elemento->name, "sqCandidato") == 0) {
         $array["sqCandidato"][$i] = $elemento->value;
         $i++;
     } else {
         $array["dtUltimaAtualizacao"][$j] = $elemento->value;
         $j++;
开发者ID:RaphaelNunes,项目名称:Raspagem,代码行数:31,代码来源:CaminhaLinks.php


注:本文中的simple_html_dom::load_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。