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


PHP scraperWiki::save方法代码示例

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


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

示例1: utf8_encode

    if (preg_match("/[0-9]+\\.[0-9]+\\.[0-9]+/", $dam->href, $m)) {
        $uidDam = $m[0];
        $titDam = utf8_encode($dam->plaintext);
        $urlInf = $urlBase . $dam->href;
        $txtInf = utf8_encode(scraperWiki::scrape($urlInf));
        preg_match_all("/((?:Sone :)|(?:.st  :)|(?:Nord :)) <B>([^<]+)</u", $txtInf, $m, PREG_SET_ORDER);
        foreach ($m as $kv) {
            $pos[$kv[1]] = $kv[2];
        }
        $utmDam = sprintf("%sN %s %s", $pos["Sone :"], $pos["Nord :"], $pos["Øst  :"]);
        $urlDam = $urlBase . str_replace('index.html', 'basis.txt', $dam->href);
        $txtDam = scraperWiki::scrape($urlDam);
        $arrDam = explode("\n", $txtDam);
        $lenArr = count($arrDam);
        for ($i = 2; $i < $lenArr; $i++) {
            $row = array();
            $ln = $arrDam[$i];
            foreach ($fmtSampleFixed as $col => $pos) {
                $row[$col] = trim(substr($ln, $pos["offset"], $pos["length"]));
            }
            if (!is_numeric($row["level"])) {
                continue;
            }
            $row["time"] = sprintf("%s-%s-%s %s:%s:00", substr($row["time"], 0, 2), substr($row["time"], 2, 2), substr($row["time"], 4, 4), substr($row["time"], 9, 2), substr($row["time"], 11, 2));
            $row["id_dam"] = $uidDam;
            $row["dam"] = $titDam;
            $row["utm_pos"] = empty($utmDam) ? "NULL" : $utmDam;
            scraperWiki::save(array('id_dam', 'time'), $row);
        }
    }
}
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:31,代码来源:norwegian_dam_levels.php

示例2: array

<?php

# Blank PHP
require 'scraperwiki/simple_html_dom.php';
$i = 1;
$html = scraperWiki::scrape("http://www.quora.com/Placerville-CA/What-is-nightlife-like-in-Placerville-CA");
scraperWiki::save(array('id' => $i), array('id' => $i, 'html' => $html->outertext));
# Blank PHP
require 'scraperwiki/simple_html_dom.php';
$i = 1;
$html = scraperWiki::scrape("http://www.quora.com/Placerville-CA/What-is-nightlife-like-in-Placerville-CA");
scraperWiki::save(array('id' => $i), array('id' => $i, 'html' => $html->outertext));
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:12,代码来源:quora_data.php

示例3: str_get_html

<?php

require 'scraperwiki/simple_html_dom.php';
$res = scraperWiki::scrape("http://www.onewaytextlink.com/links.php?type=free&pagenum=1");
$html = str_get_html($res);
$id = 0;
foreach ($html->find("a") as $data) {
    $record = array('id' => $id, 'url' => $data->href);
    scraperWiki::save(array('id'), $record);
    $id++;
}
require 'scraperwiki/simple_html_dom.php';
$res = scraperWiki::scrape("http://www.onewaytextlink.com/links.php?type=free&pagenum=1");
$html = str_get_html($res);
$id = 0;
foreach ($html->find("a") as $data) {
    $record = array('id' => $id, 'url' => $data->href);
    scraperWiki::save(array('id'), $record);
    $id++;
}
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:20,代码来源:helloworld_4.php

示例4: grab12

function grab12($url, $name)
{
    $html = scraperWiki::scrape($url);
    $html = preg_replace('/<span style="display:none">(\\d+)<\\/span>/', '', $html);
    $html = preg_replace('/<span class="\\d+">(\\d+)<\\/span>/', '\\1', $html);
    preg_match_all('/\\d+\\.\\d+\\.\\d+\\.\\d+/', $html, $ips);
    foreach ($ips[0] as $ip) {
        $record = array('ip' => $ip, 'name' => $name);
        scraperWiki::save(array('ip'), $record);
    }
}
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:11,代码来源:web_proxy_scraper_copy.php

示例5: simple_html_dom

    scraperWiki::save(array("id"), $data);
    # Fortsett med neste rad...
}
# Ferdig når det ikke er flere rader igjen i $rows.
# Sett inn ekstern fil med Simple HTML DOM-biblioteket:
require "scraperwiki/simple_html_dom.php";
# Hent HTML-koden fra nettstedet og lagre i $h:
$h = scraperWiki::scrape("http://car.espenandersen.no/?data=1");
# Konstruere et tomt HTML-tre og lagre objektet i $tree:
$tree = new simple_html_dom();
# Last HTML-koden fra nettstedet inn i HTML-treet:
$tree->load($h);
# La $tbody representere <tbody>, bruk stien:
$tbody = $tree->find("html body table tbody", 0);
# Dataradene er barn av <tbody>, kall metoden children():
$rows = $tbody->children();
# For hver rad blant dataradene...
foreach ($rows as $row) {
    # Gjør klar tom array:
    $data = array();
    # Fyll arrayen med skrapede data, feltnavn som nøkler:
    $data["id"] = $row->find("td", 0)->plaintext;
    $data["skolenavn"] = $row->find("td", 1)->plaintext;
    $data["kommunenr"] = $row->find("td", 2)->plaintext;
    $data["kommune"] = $row->find("td", 3)->plaintext;
    $data["inneklima"] = $row->find("td", 4)->plaintext;
    # Lagre dataraden (arrayen) til databasen i ScraperWiki:
    scraperWiki::save(array("id"), $data);
    # Fortsett med neste rad...
}
# Ferdig når det ikke er flere rader igjen i $rows.
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:31,代码来源:bokprosjekt_skoler.php


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