本文整理匯總了PHP中scraperWiki::save_var方法的典型用法代碼示例。如果您正苦於以下問題:PHP scraperWiki::save_var方法的具體用法?PHP scraperWiki::save_var怎麽用?PHP scraperWiki::save_var使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scraperWiki
的用法示例。
在下文中一共展示了scraperWiki::save_var方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: simple_html_dom
$html = scraperWiki::scrape("http://www.who.int/csr/don/archive/disease/en/index.html");
$dom = new simple_html_dom();
$dom->load($html);
$handleNextEntry = false;
// no previous entries -> start from beginning
if ($start == '') {
$handleNextEntry = true;
} else {
print "starting after: {$start}\n\n";
}
foreach ($dom->find("ul[@class='a_z'] li a") as $data) {
$disease = trim($data->plaintext);
print "fetching data for disease: {$disease}";
if ($handleNextEntry) {
print "\n";
// saves entries themselves
fetchGARArchive($data->href, $disease);
// saves last scraped disease
scraperWiki::save_var('disease', $disease);
if ($counter >= 600) {
exit;
}
} else {
print " - skipped\n";
if ($disease == $start) {
$handleNextEntry = true;
}
}
}
scraperWiki::save_var('disease', '');
示例2: str_replace
$tosave['PrimarySource'] = str_replace('PRIMARY SOURCE: ', '', $dom2->find("table", 1)->find("tr", 1)->plaintext);
foreach ($dom2->find("table", 0)->find("tr") as $tr) {
$tds = $tr->find("td");
if (count($tds) == 2) {
$add = $tds[1]->plaintext;
$add = str_replace(' ', '', $add);
//remove double spaces
if ($add == ' ') {
$add = '';
}
//format blanks correctly
//$add=str_replace('ë','\u00CB',$add); //fix UTF error with one school
//$add=str_replace('Ü','\u00DC',$add); //fix UTF error
$add = utf8_encode($add);
$key = $tds[0]->plaintext;
$key = str_replace(' ', '', $key);
//remove spaces from key
$tosave[$key] = $add;
}
}
//print_r($tosave);
//print $data->value;
try {
scraperwiki::save(array('EMISNumber'), $tosave);
} catch (Exception $e) {
print 'Caught exception (' . $data->value . '): ' . $e->getMessage() . "\n";
}
//break; //uncomment to just process one school
}
scraperWiki::save_var('place', 'none');
開發者ID:flyeven,項目名稱:scraperwiki-scraper-vault,代碼行數:30,代碼來源:schools_in_the_western_cape_south_africa_1.php