當前位置: 首頁>>代碼示例>>PHP>>正文


PHP scraperwiki::get_metadata方法代碼示例

本文整理匯總了PHP中scraperwiki::get_metadata方法的典型用法代碼示例。如果您正苦於以下問題:PHP scraperwiki::get_metadata方法的具體用法?PHP scraperwiki::get_metadata怎麽用?PHP scraperwiki::get_metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scraperwiki的用法示例。


在下文中一共展示了scraperwiki::get_metadata方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: time

$date = time();
$arr = array("name", "breed", $date, $latlng);
# Metadata functions.
$latest_message = scraperwiki::get_metadata('keyname', $default = 'No message yet');
print $latest_message;
$latest_message = 'Scraper input';
scraperwiki::save_metadata('latest_message', $latest_message);
$arr = array("breed", "name");
# Test scraper for PHP language.
# Should contain all our documented PHP functions.
# A fail in this scraper indicates a code failure somewhere.
require 'scraperwiki/simple_html_dom.php';
# Scrape function.
# TODO: Clarify, can we send POST parameters? Does not fail.
$arr = array("foo" => "bar");
$html = scraperwiki::scrape("http://scraperwiki.com/hello_world.html", $arr);
print $html;
# Geo function.
$latlng = scraperwiki::gb_postcode_to_latlng("E1 5AW");
print $latlng[0];
# Save function including date and latlng.
$arr = array('name' => 'Fluffles', 'breed' => 'Alsatian');
scraperwiki::save(array('name'), $arr);
$date = time();
$arr = array("name", "breed", $date, $latlng);
# Metadata functions.
$latest_message = scraperwiki::get_metadata('keyname', $default = 'No message yet');
print $latest_message;
$latest_message = 'Scraper input';
scraperwiki::save_metadata('latest_message', $latest_message);
$arr = array("breed", "name");
開發者ID:flyeven,項目名稱:scraperwiki-scraper-vault,代碼行數:31,代碼來源:testing_for_php.php

示例2: unset

        $th = $tabletr->find("th");
        $tds = $tabletr->find("td");
        $record[$th[0]->plaintext] = $tds[1]->plaintext;
        unset($th);
        unset($tds);
    }
    unset($tabletrs);
    $dom->__destruct();
    unset($dom);
    unset($html);
    scraperwiki::save(array('ID', 'sector'), $record);
    sleep(2);
    return $record;
}
$sourcescraper = 'tedscrapper';
$lasttime = scraperwiki::get_metadata('lasttime', -1);
scraperwiki::attach($sourcescraper);
print "Querying for data\n";
$data = scraperwiki::sqliteexecute("select distinct time, sector, url from tedscrapper.swdata where time >= '" . $lasttime . "' order by time");
print count($data->data) . " items to process\n";
$count = 0;
foreach ($data->data as $ind => $item) {
    $time = $item[0];
    $sector = $item[1];
    $url = $item[2];
    $record = scrapeTEDDataPage($url, $sector);
    print $count++ . " " . $record['TI'] . " " . memory_get_usage() / 1024 / 1024 . "MB\n";
    scraperwiki::save_metadata('lasttime', $time);
    unset($item);
    unset($record);
    unset($time);
開發者ID:flyeven,項目名稱:scraperwiki-scraper-vault,代碼行數:31,代碼來源:tedscrapper_page.php

示例3: begin

function begin()
{
    $dateFrom = scraperwiki::get_metadata("datefrom", "1980-01-01");
    $dateTo = scraperwiki::get_metadata("dateto", "1980-01-01");
    $dayFrom = $dateFrom;
    $dayTo = $dateTo;
    for ($i = 1; $i <= 1; $i++) {
        $nextDay = mktime(0, 0, 0, date("m", strtotime($dayFrom)), date("d", strtotime($dayFrom)) + 1, date("y", strtotime($dayFrom)));
        $dayFrom = date('Y-m-d', $nextDay);
        mainDate($dayFrom);
        scraperwiki::save_metadata("datefrom", date('Y-m-d', strtotime($dayFrom)));
        scraperwiki::save_metadata("dateto", date('Y-m-d', strtotime($dayTo)));
    }
}
開發者ID:flyeven,項目名稱:scraperwiki-scraper-vault,代碼行數:14,代碼來源:leeds-planning-php.php

示例4: oneline

<?php

require 'scraperwiki.php';
######################################
# Basic PHP scraper
######################################
$max = 10032586;
$counter = scraperwiki::get_metadata('counter');
for ($i = 0; $i < 1000; $i++) {
    $counter++;
    if ($counter == $max) {
        scraperwiki::save_metadata('counter', 10000000);
        $i = 1001;
    }
    $html = oneline(scraperwiki::scrape("http://www.ukrlp.co.uk/ukrlp/ukrlp_provider.page_pls_provDetails?x=&pn_p_id=" . $counter . "&pv_status=VERIFIED&pv_vis_code=L"));
    preg_match_all('|<div class="pod_main_body">(.*?<div )class="searchleft">|', $html, $arr);
    if (isset($arr[1][0])) {
        $code = $arr[1][0];
    } else {
        $code = '';
    }
    if ($code != '') {
        preg_match_all('|<div class="provhead">UKPRN: ([0-9]*?)</div>|', $code, $num);
        if (isset($num[1][0])) {
            $num = trim($num[1][0]);
        } else {
            $num = '';
        }
        preg_match_all('|</div>.*?<div class="provhead">(.*?)<|', $code, $name);
        if (isset($name[1][0])) {
            $name = trim($name[1][0]);
開發者ID:scottbw,項目名稱:ukrlp-1,代碼行數:31,代碼來源:scraper.php


注:本文中的scraperwiki::get_metadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。