1.采集的网站:http://www.abnova.com/support/publication.asp

2. 相关的代码:列表(规则采集)页面使用:phpQuery.php,可以参考:PHP curl_setopt函数用法介绍中篇

3.产品详情页面:信息(不规则采集),参考代码如下:

<?php
header('Content-Type:text/html;charset=UTF-8');
include 'phpQuery/phpQuery.php';
set_time_limit(0);
$id = isset($_GET['id']) ? intval($_GET['id']) : 1;$listArr = file('list.txt');if (!array_key_exists($id,$listArr)){echo 'finished';exit;
}$url = preg_replace('/[\r\n]+/','',$listArr[$id]);
phpQuery::newDocumentFile($url);$artList = pq("#sub_product_info");
echo '<pre>';foreach($artList as $li){$data = array();$datacode = array();$datacode = explode('=',$url);$data['code'] = $datacode[1];$one = '';$one_a = '';$one_a = pq($li)->find("#10000 b")->html();$one_a = trim(strip_tags($one_a));if($one_a == 'Product Description:'){// echo 1;$one = pq($li)->find('#10000 li')->eq(1)->html();$one =  trim(strip_tags($one));echo "Product Description:   ".$one;   }else{echo "Product Description:   ".$one;// echo "wrong!<br/>";
    }$data['Description'] = $one;echo '<br/>';#########################$two = '';$two_a = '';$two_a = pq($li)->find("#90000 b")->html();$two_a = trim(strip_tags($two_a));if($two_a == 'Immunogen:'){$two = pq($li)->find('#90000 li')->eq(1)->html();$two =  trim(strip_tags($two));echo "Immunogen:   ".$two;   }else{echo "Immunogen:   ".$two;// echo "wrong<br/>";
    }$data['Immunogen'] = $two;echo '<br/>';#########################$three = '';$three_a = '';$three_a = pq($li)->find("#110000 b")->html();$three_a = trim(strip_tags($three_a));if($three_a == 'Host:'){$three = pq($li)->find('#110000 li')->eq(1)->html();$three =  trim(strip_tags($three));echo "Host:   ".$three;   }else{echo "Host:   ".$three;// echo "wrong<br/>";
    }$data['Host'] = $three;echo '<br/>';#########################$four = '';$four_a = '';$four_a = pq($li)->find("#130000 b")->html();$four_a = trim(strip_tags($four_a));if($four_a == 'Reactivity:'){$four = pq($li)->find('#130000 li')->eq(1)->html();$four =  trim(strip_tags($four));echo "Reactivity:   ".$four;   }else{echo "Reactivity:   ".$four;// echo "wrong<br/>";
    }$data['Reactivity'] = $four;echo '<br/>';#########################$five = '';$five_a ='';$five_a = pq($li)->find("#240000 b")->html();$five_a = trim(strip_tags($five_a));if($five_a == 'Isotype:'){$five = pq($li)->find('#240000 li')->eq(1)->html();$five =  trim(strip_tags($five));echo "Isotype:   ".$five;   }else{echo "Isotype:   ".$five;// echo "wrong<br/>";
    }$data['Isotype'] = $five;echo '<br/>';#########################$six = '';$six_a = '';$six_a = pq($li)->find("#290000 b")->html();$six_a = trim(strip_tags($six_a));if($six_a == 'Quality Control Testing:'){$six_all = pq($li)->find('#290000 li')->eq(1)->html();$six_all =  trim(strip_tags($six_all,"<br>"));// $six_all = str_replace("<br><br><br/>",'###',)$six_arr = explode("<br><br><br>",$six_all);// var_dump($six_arr);$six = trim($six_arr[0]);   echo "Quality Control Testing:    ".$six;   }else{echo "Quality Control Testing:    ".$six;// echo "wrong<br/>";
    }$data['Testing'] = $six;echo '<br/>';echo '<hr/>';#########################$wh_11 = '';$wh_11 = pq($li) -> find(".part")->eq(2)->find(".first_title b")->html();$wh_11 = trim(strip_tags($wh_11));echo "APP:   ".$wh_11;echo '<br/>';$wh_22 = '';$wh_22 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(1)->find("li")->eq(0)->html();$wh_22 = trim(strip_tags($wh_22));echo "Western:   ".$wh_22;echo '<br/>';$wh_33 = '';$wh_33 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(2)->find("li")->eq(0)->html();$wh_33 = trim(strip_tags($wh_33));echo "Western Blot:   ".$wh_33;echo '<br/>';$wh_44 = '';$wh_44 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(3)->find("li")->eq(0)->html();$wh_44 = trim(strip_tags($wh_44));echo "Immunohistochemistry:    ".$wh_44;echo '<br/>';$wh_55 = '';$wh_55 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(4)->find("li")->eq(0)->html();$wh_55 = trim(strip_tags($wh_55));echo "Immunofluorescence:    ".$wh_55;echo '<br/>';$wh_66 = '';$wh_66 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(5)->find("li")->eq(0)->html();$wh_66 = trim(strip_tags($wh_66));echo "Sandwich ELISA:   ".$wh_66;echo '<br/>';$wh_77 = '';$wh_77 = pq($li) -> find(".part")->eq(2)->find("ul")->eq(6)->find("li")->eq(0)->html();$wh_77 = trim(strip_tags($wh_77));echo "ELISA:   ".$wh_77;echo '<br/>';$app = array();$appstr = '';if ($wh_22 != '') $app['w1'] = $wh_22;if ($wh_33 != '') $app['w2'] = $wh_33;if ($wh_44 != '') $app['w3'] = $wh_44;if ($wh_55 != '') $app['w4'] = $wh_55;if ($wh_66 != '') $app['w5'] = $wh_66;if ($wh_77 != '') $app['w6'] = $wh_77;echo $appstr = implode(',',$app);$data['app'] = $appstr;echo '<hr/>';#########################// $length = pq($li) -> find(".part")->eq(3)->find("ul")->find("li")->html();// $length = trim(strip_tags($length,'<b>'));// $length = str_replace("<b>","####",$length);// // $length = str_replace("</b>",",",$length);// echo $length;// $arr = explode(",",$length);// var_dump($arr);// foreach($length as $list){//  echo $list;//  // exit;// }echo '<hr/>';echo '<br/>';$heng_11 = '';$heng_11_a = '';$heng_11_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(1)->find("li")->eq(0)->find("b")->html();$heng_11_a = trim(strip_tags($heng_11_a));if($heng_11_a == 'Entrez GeneID:'){$heng_11 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(1)->find("li")->eq(1)->find("a")->html();$heng_11 = trim(strip_tags($heng_11));echo "Entrez GeneID:   ".$heng_11;}else{echo "Entrez GeneID:   ".$heng_11;}$data['GeneID'] = $heng_11;echo '<br/>';$heng_22 = '';$heng_22_a = '';$heng_22_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(2)->find("li")->eq(0)->find("b")->html();$heng_22_a = trim(strip_tags($heng_22_a));if($heng_22_a == 'GeneBank Accession#:'){$heng_22 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(2)->find("li")->eq(1)->find("a")->html();$heng_22 = trim(strip_tags($heng_22));echo "GeneBank Accession#:   ".$heng_22;}else{echo "GeneBank Accession#:   ".$heng_22;}$data['GeneBank Accession'] = $heng_22;echo '<br/>';$heng_33 = '';$heng_33_a = '';$heng_33_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(3)->find("li")->eq(0)->find("b")->html();$heng_33_a = trim(strip_tags($heng_33_a));if($heng_33_a == 'Protein Accession#:'){$heng_33 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(3)->find("li")->eq(1)->find("a")->html();$heng_33 = trim(strip_tags($heng_33));echo "Protein Accession#:   ".$heng_33;}else{echo "Protein Accession#:   ".$heng_33;}$data['Protein Accession'] = $heng_33;echo '<br/>';$heng_44 = '';$heng_44_a = '';$heng_44_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(4)->find("li")->eq(0)->find("b")->html();$heng_44_a = trim(strip_tags($heng_44_a));if($heng_44_a == 'Gene Name:'){$heng_44 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(4)->find("li")->eq(1)->html();$heng_44 = trim(strip_tags($heng_44));echo "Gene Name:   ".$heng_44;}else{echo "Gene Name:    ".$heng_44;}$data['Gene Name'] = $heng_44;echo '<br/>';$heng_55 = '';$heng_55_a = '';$heng_55_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(5)->find("li")->eq(0)->find("b")->html();$heng_55_a = trim(strip_tags($heng_55_a));if($heng_55_a == 'Gene Alias:'){$heng_55 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(5)->find("li")->eq(1)->html();$heng_55 = trim(strip_tags($heng_55));echo "Gene Alias:   ".$heng_55;}else{echo "Gene Alias:  ".$heng_55;}
$data['Gene Alias'] = $heng_55;echo '<br/>';$heng_66 = '';$heng_66_a = '';$heng_66_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(7)->find("li")->eq(0)->find("b")->html();$heng_66_a = trim(strip_tags($heng_66_a));if($heng_66_a == 'Omim ID:'){$heng_66 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(7)->find("li")->eq(1)->html();$heng_66 = trim(strip_tags($heng_66));echo "Omim ID:  ".$heng_66;}else{echo "Omim ID:  ".$heng_66;}
$data['Omim ID'] = $heng_66;echo '<br/>';$heng_77 = '';$heng_77_a = '';$heng_77_a = pq($li) -> find(".part")->eq(3)->find("ul")->eq(8)->find("li")->eq(0)->find("b")->html();$heng_77_a = trim(strip_tags($heng_77_a));if($heng_77_a == 'Gene Ontology:'){$heng_77 = pq($li) -> find(".part")->eq(3)->find("ul")->eq(8)->find("li")->eq(1)->find("a")->html();$heng_77 = trim(strip_tags($heng_77));echo "Gene Ontology:   ".$heng_77;}else{echo "Gene Ontology:   ".$heng_77;}$data['Gene Ontology'] = $heng_77;# 获取文献$rarr = array();$Reference = '';if (preg_match('/Publication Reference/',$li->textContent)){preg_match_all('/Publication Reference(.*?)Applications/',preg_replace('/[\r\n]+/','',$li->textContent),$rarr);}$Reference = $rarr[1][0];$data['Reference'] = $Reference;$rarr = array();print_r($data);# 写入文件 $handle = fopen('list-new.csv','a');fputcsv($handle,$data);fclose($handle);}?>
<script>
function JumpUrl(){location.href='?id=<?php echo ($id+1);?>';
}
setTimeout('JumpUrl()',0);
</script>

对网站的代码采集实例相关推荐

  1. jquery中邮箱地址 URL网站地址正则验证实例代码

    jquery中邮箱地址 URL网站地址正则验证实例代码 QQ网站有一个网站举报的功能,看了一些js代码觉得写得很不错,我就拿下来了,下面是一个email验证与url网址验证js代码,分享给大家 ema ...

  2. 10种网站数据的采集方法

    10种AI训练数据采集工具排行榜 10种网站数据的采集方法 1.目前常用的10种网站数据 2.如何写Python爬虫: 3.人生第一个 爬虫代码示例: 另外: 10种网站数据的采集方法 如何收集网站数 ...

  3. 网站文章被采集?尝试使用这几种方法进行最大防护

    站长,在做网站的时候,时有发生网站内容被采集的情况,特别是现在这种采集成本极低的环境,只要稍微会一点代码,就可以制作采集模块.即便不会代码,也可以花费低廉的价格去找人代写. 新站上线,勤勤恳恳的做着原 ...

  4. 如何防止网站内容被采集

    很多防采集方法在施行的时候需要考虑是否影响搜索引擎对网站的抓取,所以先来分析下一般采集器和搜索引擎爬虫采集有何不同. 相同点: a. 两者都需要直接抓取到网页源码才能有效工作, b. 两者单位时间内会 ...

  5. 【Python】5行代码采集3000+上市公司信息

    前言 毕业季也到了找工作的季节了,很多小伙伴都会一家一家的公司去看,这得多浪费时间啊.今天用Python教大家怎么采集公司的 信息,相信大家会很喜欢这个教程的,nice! 基本环境配置 ◾版本:Pyt ...

  6. seo采集,网站seo免费采集,seo采集方法技巧

    seo采集,是指通过一些采集规则的程序,全自动地将其他网站的文章内容采集发布到自己的网站.seo采集配合一定的技巧或伪原创,seo采集的文章可以帮助站长提升自己网站的排名.seo采集不用花费大量时间去 ...

  7. python——5行代码采集3000+上市公司信息

    毕业季也到了找工作的季节了,很多小伙伴都会一家一家的公司去看,这得多浪费时间啊.今天用Python教大家怎么采集公司的信息,相信大家会很喜欢这个教程的,nice! 基本环境配置 ◾版本:Python3 ...

  8. legend3---2、网站的代码里面的/也是代表根目录

    legend3---2.网站的代码里面的/也是代表根目录 一.总结 一句话总结: 不过这个根目录在public下面 1.mysql删除数据库命令? drop database <数据库名> ...

  9. php网站怎么缓存,一个php网站缓存代码分享

    一个php网站缓存代码分享,有需要的朋友可以参考下. 复制代码 代码如下: /** * @author Seraphim * @copyright 2012 * @link http://www.jq ...

最新文章

  1. 彻底剖析室内、室外激光SLAM关键算法原理、代码和实战(cartographer+LOAM+LIO-SAM)
  2. 复合数值积分方法以及Python程序实现
  3. 有关数据库MySQL的演讲_有关Mysql数据库编程的文章推荐10篇
  4. 终于,一键打通微信和QQ
  5. jsch 移动服务器上文件,jsch上传文件到服务器
  6. js实现类名的添加与移除
  7. 华硕电池管理软件_多模式无线电竞鼠标怎么选?华硕?ROG 烈刃2 上手体验
  8. python程序封装成exe_如何将python脚本封装成exe程序?
  9. python中response对象的属性_关于python:AttributeError:’HTTPResponse’对象没有属性’split’...
  10. [转载] python实现一个简易的计算器
  11. vip会员统计表 (vip等级是灵活配置的 非写死1是金卡用户 2是什么 等)
  12. ubuntu字符界面login_关于Ubuntu循环登陆界面
  13. CxImage入门教程,图文并茂
  14. CAD转图片如何调整输出格式?
  15. css控制表格剧中,如何通过css设置表格居中
  16. 指投:3 常见的指数基金品种
  17. CSS网页布局中易犯的30个小错误
  18. echarts:基于上一篇我来给大家讲讲 如果你设置了自动播放但是鼠标放上去不生效 停留时间很短 应该怎么做呢???
  19. codeforces 1438C、Engineer Artem
  20. Android DoraemonKit 教程和简介

热门文章

  1. Android底层禁用WiFi和蓝牙功能
  2. 游戏计算机性能要求,游戏主机只能玩游戏?只要性能够强悍,什么需求都能满足!...
  3. docker新建Linux虚拟机,RHEL/CentOS 7下创建你的第一个Docker容器
  4. C#教程3:基本语言结构
  5. 关于jq+easy-ui 中上传文件所遇到的问题
  6. android 地图相册,时光地图相册
  7. git与github区别与简介
  8. 【C++】37.为什么要使用Lambda表达式
  9. 使用JBoss Modules来模块化Java
  10. 作为怀孕的亲历者,你觉得最值得分享的经验或者技巧是什么?