2 Star 1 Fork 0

vForce/extract-39net-disease-sympton-department

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extract.php 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
<?php
header("Content-Type:text/html;charset=utf-8");
include_once "util.php";
include_once "diseasePages.php";
include_once "symptonPages.php";
/**
* @var array $diseasePages
* @var array $symptonPages
*/
$alias = []; $department = []; $symptons = []; $totalSympton = []; $position = [];
$i = 1; $total = count($diseasePages);
foreach ($diseasePages as $name => $url) {
$content = getHTML($url . "jbzs/");
$zztzContent = getHTML($url . "zztz/");
//抽别名
preg_match("/<dd><i>别名:<\/i> (.*)<\/dd>/U", $content, $match);
$alias[$name] = explode(",", str_replace(",", ",", $match[1]));
//抽相关症状
preg_match("/相关症状.*<\/dd>/siU", $zztzContent, $match);
preg_match_all("/http:\/\/jbk.39.net\/zhengzhuang\/\w+\/.*title=\"(.*)\"/siU", $match[0], $matches);
$symptons[$name] = $matches[1];
//抽症状库
foreach ($matches[1] as $sympton) {
if (array_search($sympton, $totalSympton) == false) $totalSympton[] = $sympton;
}
//抽部位
preg_match("/发病部位.*<\/dd>/siU", $content, $match);
preg_match_all("/<a href='\/bw\/\w+\/'>(.*)<\/a>/U", $match[0], $matches);
$position[$name] = $matches[1];
//抽科室
preg_match("/就诊科室.*<\/dd>/siU", $content, $departmentContent);
preg_match_all("/href='\/bw\/\w+\/'>(.*)<\/a>/U", $departmentContent[0], $matches);
$department[$name] = $matches[1];
echo "Disease Page Analyzed: {$i}/{$total}\n"; $i++;
}
$i = 1; $total = count($symptonPages);
foreach ($symptonPages as $name => $url) {
$content = getHTML($url . "zzqy/");
if (!in_array($name, $totalSympton)) $totalSympton[] = $name;
//抽症状相关疾病
preg_match("/可能疾病.*<\/table>/siU", $content, $possibleDiseases);
preg_match_all("/http:\/\/jbk.39.net\/\w+\/.*title=\"(.*)\"/U", $possibleDiseases[0], $matches);
foreach ($matches[1] as $disease) {
if (!isset($symptons[$disease])) $symptons[$disease] = [];
if (!in_array($name, $symptons[$disease])) $symptons[$disease][] = $name;
}
echo "Sympton Page Analyzed: {$i}/{$total}\n"; $i++;
}
dumpVariableToFile($alias, "result/alias.php", "alias");
dumpVariableToFile($department, "result/department.php", "department");
dumpVariableToFile($symptons, "result/symptons.php", "symptons");
dumpVariableToFile($totalSympton, "result/totalSympton.php", "totalSympton");
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/vforce/extract-39net-disease-sympton-department.git
git@gitee.com:vforce/extract-39net-disease-sympton-department.git
vforce
extract-39net-disease-sympton-department
extract-39net-disease-sympton-department
master

搜索帮助