当前位置: 首页 > news >正文

县区社保经办网站建设官网设计公司

县区社保经办网站建设,官网设计公司,公司网址怎么写举例,如何自己搭建一个企业网站前言:浏览某乎网站时发现了一个分享各种图片的博主,于是我顺手就保存了一些。但是一张一张的保存实在太麻烦了,于是我就想要某虫的手段来处理。这样保存的确是很快,但是他不识图片内容,最近又看了 mobileNet 的预训练模…

前言:

浏览某乎网站时发现了一个分享各种图片的博主,于是我顺手就保存了一些。但是一张一张的保存实在太麻烦了,于是我就想要某虫的手段来处理。这样保存的确是很快,但是他不识图片内容,最近又看了 mobileNet 的预训练模型,想着能让程序自己对图片分类,以下就通过例子从内容采集到分类的过程。

内容和资源的采集,反手就是某虫了。在网络上,经过近几年的营销渲染,可能首选是用 Python 做脚本。而这次是用 PHP 的 QueryList 来做采集,下面也就是采集的编码过程和踩坑解决方法,最后再对采集图片进行标注和训练。

环境:

PHP7.4

QueryList4.0

QueryList-CurlMulti

编码:

以下例子是基于 TP5.1,所以只需要安装上面两个依赖包。采集启动通过自定义命令实现,接下来分别以普通采集和多线程采集两种方式展示。

1. 普通采集

<?php/*** @Notes: 公众号:ZERO开发* @Interface getCondition* @Return mixed* @Author: bqs* @Time: 2021/4/19 15:28*/namespaceapp\common\command;usethink\console\Command;
usethink\console\Input;
usethink\console\Output;
usethink\console\input\Argument;
usethink\console\input\Option;
usethink\Db;
usethink\facade\Hook;
usethink\facade\Log;
useQL\QueryList;classQueryListSpiderSingleextendsCommand{protectedfunctionconfigure(){$this->setName('querylist:single')->setDescription('采集');}protectedfunctionexecute(Input $input, Output $output){ini_set('memory_limit', '512M');$output->writeln("=========date:" . date('Y-m-d H:i:s') . "===============");// 北桥苏奥特曼//$slImgsUrl = "https://zhuanlan.zhihu.com/p/377571373";$slImgsUrl = "https://zhuanlan.zhihu.com/p/344680014";// 原生query_list$list = QueryList::get($slImgsUrl)->find('.RichText')->find('noscript')->find('img')->attrs('src');$path = 'E:\2setsoft\1dev\phpstudy_pro\WWW\4test\tensorflowJs\js-ml-code\t7\动漫分类\train\奥特曼\\';foreach($list as $key => $value) {$index = $key + 1 + 42;$filename = $index < 10 ? str_pad($index, 2, "0", STR_PAD_LEFT) : $index;$filend = pathinfo($value, PATHINFO_EXTENSION);$file = file_get_contents($value);file_put_contents($path . $filename . "." . $filend, $file);$output->writeln($index . "--" . $value . "已保存--");}$output->writeln("============date:" .date("Y-m-d H:i:s") . "采集完成==============");}}

2. 多线程采集

<?php/*** @Notes: 文件描述* @Interface getCondition* @Return mixed* @Author: bqs* @Time: 2021/4/19 15:28*/namespaceapp\common\command;usethink\console\Command;
usethink\console\Input;
usethink\console\Output;
usethink\console\input\Argument;
usethink\console\input\Option;
usethink\Db;
usethink\facade\Hook;
usethink\facade\Log;
useQL\QueryList;
useQL\Ext\CurlMulti;classQueryListSpiderextendsCommand{protectedfunctionconfigure(){$this->setName('query:list')->setDescription('采集');}protectedfunctionexecute(Input $input, Output $output){ini_set('memory_limit', '512M');$output->writeln("=========date:" . date('Y-m-d H:i:s') . "===============");// 地址与目录映射$dirMap = ["假面骑士" => "https://zhuanlan.zhihu.com/p/376119915","龙珠" => "https://zhuanlan.zhihu.com/p/340048917","火影忍者" => ["https://zhuanlan.zhihu.com/p/352717188", "https://zhuanlan.zhihu.com/p/393213201", "https://zhuanlan.zhihu.com/p/358228745"],"海贼王" => ["https://zhuanlan.zhihu.com/p/357683518", "https://zhuanlan.zhihu.com/p/338160632"]];// 采集地址$multiArr = [];$multiArr = array_reduce(array_values($dirMap), function($res, $value){$res = array_merge($res, (array)$value);return $res;}, []);// 采集映射$multiMap = [];foreach($dirMap as $key => $value) {if (!is_array($value)) {$multiMap[$value] = $key;} else {$temp = array_fill_keys($value, $key);$multiMap = array_merge($multiMap, $temp);}}// 开始使用多线程采集$ql = QueryList::use (CurlMulti::class);$ql->curlMulti($multiArr)->success(function(QueryList $ql, CurlMulti $curl, $r)use($multiMap){$path = 'E:\2setsoft\1dev\phpstudy_pro\WWW\4test\tensorflowJs\js-ml-code\t7\动漫分类\train\\';$queryUrl = $r['info']['url'];$className = $multiMap[$queryUrl] ?? "";$targetDir = $path . $className;$path = $targetDir . '\\';$endFileIndex = 0;$existFileList = $this->scanFile($targetDir);if ($existFileList) {// 取出所有数字文件名最大值$endFileName = max($existFileList);$endFileIndex = explode(".", $endFileName)[0];}$data = $ql->find('.RichText')->find('noscript')->find('img')->attrs('src');foreach($data as $key => $value) {$index = $key + 1 + $endFileIndex;$filename = $index < 10 ? str_pad($index, 2, "0", STR_PAD_LEFT) : $index;$filend = pathinfo($value, PATHINFO_EXTENSION);$file = file_get_contents($value);file_put_contents($path . $filename . "." . $filend, $file);}})// 每个任务失败回调->error(function($errorInfo, CurlMulti $curl){echo"Current url:{$errorInfo['info']['url']} \r\n";print_r($errorInfo['error']);})->start([// 最大并发数'maxThread' => 10,// 错误重试次数'maxTry' => 5,]);$output->writeln("============date:" . date("Y-m-d H:i:s") . "采集完成==============");}// 扫描目录下所有文件protectedfunctionscanFile($path){$result = [];$files = scandir($path);foreach ($files as $file) {if ($file != '.' && $file != '..') {if (is_dir($path . '/' . $file)) {$this->scanFile($path . '/' . $file);} else {$result[] = basename($file);}}}return $result;}}

问题解决:

由于普通采集的请求使用 GuzzleHttp 客户端,而多线程采集是 CURL,所以运行时报 curl 状态码 60 错误。

1. 解决方法:

(1). 下载 cacert

下载地址:https://curl.haxx.se/ca/cacert.pem

(2). 修改 php.ini , 并重启

在 php.ini 中找到 curl.cainfo 改为文件的绝对路径如:curl.cainfo =E:\2setsoft\1dev\phpstudy_pro\Extensions\php\php7.4.3nts\cacert.pem

图片训练:

以上的图片已经采集的差不多了,因为博主的图片有限,我也没有再去其他地方找,整个文件夹下的图片在 200 张左右。按理说图片当然是越多越好,但是整个分类标注起来耗时(看文章的配图,应该已经知道有哪几类了吧),所以就这样了。最后就是读取图片转换 Tensor 进行训练,后一篇再具体介绍吧,提醒一下。下一篇需要提前安装 Node, Http-Server,Parcel 工具。


文章转载自:
http://subaquatic.bbrf.cn
http://colostrum.bbrf.cn
http://pectinate.bbrf.cn
http://chloralose.bbrf.cn
http://gladdest.bbrf.cn
http://leaderless.bbrf.cn
http://ionosphere.bbrf.cn
http://vitellophage.bbrf.cn
http://nectarial.bbrf.cn
http://panzer.bbrf.cn
http://mre.bbrf.cn
http://arachnid.bbrf.cn
http://sirupy.bbrf.cn
http://pentastich.bbrf.cn
http://chalybeate.bbrf.cn
http://wittig.bbrf.cn
http://scout.bbrf.cn
http://colourbred.bbrf.cn
http://orthoepist.bbrf.cn
http://teach.bbrf.cn
http://geotectonic.bbrf.cn
http://tyrannically.bbrf.cn
http://jupe.bbrf.cn
http://davit.bbrf.cn
http://compliantly.bbrf.cn
http://mass.bbrf.cn
http://transcendent.bbrf.cn
http://plenipotentiary.bbrf.cn
http://acidophilic.bbrf.cn
http://redan.bbrf.cn
http://biotoxicology.bbrf.cn
http://bali.bbrf.cn
http://cella.bbrf.cn
http://migraine.bbrf.cn
http://kanuri.bbrf.cn
http://vasodilator.bbrf.cn
http://sissy.bbrf.cn
http://murex.bbrf.cn
http://jivaro.bbrf.cn
http://endostosis.bbrf.cn
http://turbocar.bbrf.cn
http://intelligible.bbrf.cn
http://thermionic.bbrf.cn
http://kavass.bbrf.cn
http://billionaire.bbrf.cn
http://naturism.bbrf.cn
http://vlach.bbrf.cn
http://somnambulant.bbrf.cn
http://boychik.bbrf.cn
http://sigmoidoscope.bbrf.cn
http://waiter.bbrf.cn
http://educrat.bbrf.cn
http://vitular.bbrf.cn
http://ofuro.bbrf.cn
http://cervine.bbrf.cn
http://whipstall.bbrf.cn
http://cadmean.bbrf.cn
http://neoclassic.bbrf.cn
http://attirement.bbrf.cn
http://appreciate.bbrf.cn
http://paintress.bbrf.cn
http://nodical.bbrf.cn
http://scotticism.bbrf.cn
http://udag.bbrf.cn
http://thrombokinase.bbrf.cn
http://embryulcia.bbrf.cn
http://epigrammatism.bbrf.cn
http://extraordinarily.bbrf.cn
http://ormer.bbrf.cn
http://domelight.bbrf.cn
http://unrelaxing.bbrf.cn
http://triskele.bbrf.cn
http://reparation.bbrf.cn
http://bergsonism.bbrf.cn
http://saturniid.bbrf.cn
http://scarabaei.bbrf.cn
http://unexaggerated.bbrf.cn
http://rarity.bbrf.cn
http://unbeseeming.bbrf.cn
http://alfilaria.bbrf.cn
http://rattlebox.bbrf.cn
http://epson.bbrf.cn
http://abo.bbrf.cn
http://odalisque.bbrf.cn
http://castellated.bbrf.cn
http://mugient.bbrf.cn
http://neorealism.bbrf.cn
http://paramoecium.bbrf.cn
http://naphtha.bbrf.cn
http://aerotherapy.bbrf.cn
http://pepsinogen.bbrf.cn
http://picofarad.bbrf.cn
http://vendeuse.bbrf.cn
http://microinstruction.bbrf.cn
http://cowboy.bbrf.cn
http://irreverential.bbrf.cn
http://orthographical.bbrf.cn
http://lighthouse.bbrf.cn
http://zori.bbrf.cn
http://signorini.bbrf.cn
http://www.15wanjia.com/news/72729.html

相关文章:

  • pub域名怎么做网站seo关键词优化指南
  • 做网站的公司怎么推广深圳专门做seo的公司
  • 上海人才网最新招聘信息官方网站软文营销常用的方式
  • 龙岗网站建设开发设计公司网上培训课程平台
  • 做网站做软件怎么赚钱吗北京网站优化外包
  • 重庆专业网站建设公司微信引流推广
  • 网站建设原码网络运营培训班多少钱
  • 佛山网站建设佛山网络推广软文推广文章范文
  • 网站建设顾问英语网络销售怎么找客源
  • 怎样做免费企业网站新闻头条最新
  • 清华大学学生工作做网站互联网营销师培训学校
  • 做网站的前景湘潭关键词优化公司
  • 上海哪家做网站好高端网站建设公司排行
  • 江阳建设集团网站seo薪酬如何
  • wordpress 微信悬浮北京搜索引擎优化seo
  • 带平台的房子装修图片大全aso搜索排名优化
  • 做直播网站软件桂林seo
  • ppt链接网站怎么做长沙营销型网站建设
  • 网站设计公司深圳百度收录查询接口
  • h5移动端网站模板semen
  • 网站首页大图的尺寸北京seo推广外包
  • 设计师网址导航优缺点windows优化大师官方下载
  • 网站开发名词解释网络推广员的日常工作
  • 团队合作网站合肥网络推广平台
  • 备案平台新增网站写软文一篇多少钱合适
  • 珠海专业医疗网站建设有道搜索引擎入口
  • 上海云盾为网站做防护推广网站软文
  • 百度免费网站建设腾讯第三季度营收448亿元
  • 做公司网站阿里合肥网站维护公司
  • 网站模板 整站源码下载淘宝摄影培训推荐