[PHP][学习笔记][CURL]监测设备运行情况小demo
2024-08-29 16:19:09
1.curl获取的web content 不能直接echo到页面,会造成js各种错误
2.想办法处理字符串的截取、拼接
2.1.裁剪html返回的字符串
function cutStringFrom($mainStr,$toCunSampleStr){
// 保存要被裁剪的字符串
$cuttedStr = $mainStr;
// 要裁剪的字符串样本
$targetString = $toCunSampleStr;
// 先找到 样本字符串 位置
$index = strpos($cuttedStr,$targetString);
// 样本字符串长度
$targetStringLength = strlen($targetString);
// 开始截断
$cuttedStr = substr($cuttedStr,$index + $targetStringLength);
// 返回截断后结果
return $cuttedStr;
}
2.2.从字符串的最前面两个双引号之前取出数值
function getStringBetweenDoubleMarks($mainStr){
// 保存要查找内容的原字符串
$cuttedStr = $mainStr;
// 找到第一个"
$strRemovedFirstMark = cutStringFrom($cuttedStr,"\"");
$indexNextMark = strpos($strRemovedFirstMark,"\"");
$valueBetweenDoubuleMark = substr($strRemovedFirstMark,0,$indexNextMark);
return $valueBetweenDoubuleMark;
}
2.3获取设备呼叫统计参数
function getCallSummary($html){
$htmlContent = $html;
$propertyValue = array();
$propertyName = array("g_WebPort","kIpAddress","sysName","CALLTIME","CALLTOTALNUMBER","IPCALLTOTALNUMBER","IPCALLTOTALTIME","PERCENT_IP_CALLS","ISDNCALLTOTALNUMBER","ISDNCALLTOTALTIME","PERCENT_ISDN_CALLS");
foreach ($propertyName as $value){
$htmlContent = cutStringFrom($htmlContent,$value);
$propertyValue[] = getStringBetweenDoubleMarks($htmlContent);
}
return $propertyValue;
}
最新文章
- 如何有效使用Project(2)——进度计划的执行与监控
- Mock模拟后台数据接口--再也不用等后端的API啦
- 在C#中读写INI配置文件(转)
- Asp.net MVC中的ViewData与ViewBag
- [ES6] 20. Polyfills
- C# 图解教程 第五章 方法
- MongoDb进阶实践之七 MongoDB的索引入门
- C#winform窗口登录和数据的增删改查
- python验证码识别接口及识别思路代码
- 【codeforces】【Round#523D】TV shows
- [Agc005D]K Perm Counting
- redmine一键安装(项目管理、Bug管理、任务跟踪、代码管理、日报等等)
- 用Telnet测试服务器的端口是否开通
- Netty 零拷贝(一)NIO 对零拷贝的支持
- 201709013工作日记--Android消息机制HandlerThread
- ubuntu server 安装nextcloud12
- 手机端全局样式表整理(mobile)
- 课堂实验-Bag
- [svc]entrypoint.sh shell脚本解析
- 编写高质量代码改善C#程序的157个建议——建议92:谨慎将数组或集合作为属性
热门文章
- 使用Python的Flask框架,结合Highchart,动态渲染图表(Ajax 请求数据接口)
- Scrapy实战:使用scrapy再再次爬取干货集中营的妹子图片
- defer, panic, recover使用总结
- 【tips】ORM - SQLAlchemy操作MySQL数据库
- GeoTrust 企业(OV)型 增强版(EV) SSL证书
- Android学习总结(5)——9个非常有用的Andorid 程序片段
- hdu 4941 stl的map<;node,int>;用法
- readl()和writel()
- Spring MVC-集成(Integration)-生成RSS源示例(转载实践)
- N天学习一个Linux命令之free