(phpQuery)对网站产品信息采集代码的优化
16lz
2021-01-22
a.要采集的源链接:
http://www.prospecbio.com/Recombinant_Proteins/
b.具体要求:
接下来就是采集代码的编写。
对于:b-(1)中,代码如下:
<?php header('Content-Type:text/html;charset=UTF-8'); include './phpQuery/phpQuery.php'; set_time_limit(10000); $url = "http://www.prospecbio.com/Hormones/"; echo "当前的URL:"; echo $url."<br/>"; phpQuery::newDocumentFile($url); $artList = pq(".Body"); // var_dump($artList); $li = ''; foreach($artList as $li){ $path = ''; $head = ''; $head = 'http://www.prospecbio.com'; $tr = ''; $tr = pq($li)->eq(0)->find("table")->eq(0)->find("tr")->eq(0)->find("td")->eq(0)->find("a")->eq(0)->attr('href'); $tr = trim($tr); if($tr != ''){ $path = $head.$tr; // var_dump($path); $path .= "\r\n"; file_put_contents('Url.txt',$path,FILE_APPEND); } // exit; } ?>
更多相关文章
- 用于上传多个文件的PHP代码
- 韩顺平_php从入门到精通_视频教程_学习笔记_源代码图解_PPT文档
- 【MySQL 技巧分享】 mysql -e 加 v 简化代码
- Oracle相当于MySQL代码“插入虚拟”以返回错误消息
- 登录使用PHP并´t显示任何html代码
- 一些值得收藏的MySQL知识链接
- 在代码点火器中从mysql迁移到postgresql
- 【动软.Net代码生成器】连接MySQL生成C#的POCO实体类(Model)
- 简单的插入语句不能在PHP代码中工作。适用于MySQL Workbench