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 使用matlab将观测点聚合成多条目标轨迹
  • ¥15 Workbench中材料库无法更新,如何解决?
  • ¥20 如何推断此服务器配置
  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析