doujia9833 2015-05-09 14:54
浏览 72
已采纳

PHP preg_match()获取javascript内容

I am working on a data scraping project and I need to extract some data from the script tag inside a html page

<script type="text/javascript">
jQuery(document).ready( function(){
    new Equator.dataTable.loadEQDataTable( '33F6AC0950569B89A6D81D719B651143', '/proxy/ajaxproxy.cfc?method=process&event=property.getWorkflowByTask&marshalType=dataTable&sListColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&nTargetID=17801&nIsOpen=2&sEventType=form,form_html,rfi', '9', 'asc', 'true', 'true', 'index.cfm?event=property.getWorkflowByTask&sListColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&sListLabels=Task,Address,City,State,Zip,Status,Role,Servicer,Opened,Due/Completed&sListExcelColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&sListExcelLabels=Task,Address,City,State,Zip,Status,Role,Servicer,Opened,Due/Completed&bExcel=true&nTargetID=17801&nIsOpen=2&sEventType=form,form_html,rfi&iSortCol_0=9&sSortDir_0=asc', '', '25', 'false', '',false, true, '');
    });
</script>

In which I need to extract

/proxy/ajaxproxy.cfc?method=process&event=property.getWorkflowByTask&marshalType=dataTable&sListColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&nTargetID=17801&nIsOpen=2&sEventType=form,form_html,rfi', '9', 'asc', 'true', 'true', 'index.cfm?event=property.getWorkflowByTask&sListColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&sListLabels=Task,Address,City,State,Zip,Status,Role,Servicer,Opened,Due/Completed&sListExcelColumns=EVENT_NAME,ADDRESS_1,CITY,STATE,POSTAL_CODE,status_value,ROLE_DISPLAY,LENDERNAME,OPEN_DATE,DUEDATE&sListExcelLabels=Task,Address,City,State,Zip,Status,Role,Servicer,Opened,Due/Completed&bExcel=true&nTargetID=17801&nIsOpen=2&sEventType=form,form_html,rfi&iSortCol_0=9&sSortDir_0=asc
  • 写回答

1条回答 默认 最新

  • dongzhao8233 2015-05-09 22:20
    关注

    You can get the second parameter with:

    preg_match_all("/'(.*?)'/", $script, $m);
    echo $m[1][1];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。
  • ¥15 SQL Server analysis services 服务安装失败
  • ¥15 用html创建一个个人网页,提供网页页面
  • ¥20 java项目连接SqlServer数据库报错
  • ¥15 基于面向对象的图书馆借阅管理系统
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥20 centos linux 7.9安装php8.2.18不支持mysqli模块的问题
  • ¥15 stata空间计量LM检验
  • ¥15 关于k8s node节点被释放后如何驱逐节点并添加新节点
  • ¥15 subprocess.CalledProcessError: Command ‘[‘ninja‘, ‘-v‘]‘ returned non-zero exit status 1