本文整理汇总了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