PHP preg_match()获取javascript内容

时间:2015-05-09 14:54:10

标签: php parsing simple-html-dom

我正在开展数据抓取项目 我需要从html页面内的脚本标签中提取一些数据

<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>

我需要提取

/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 个答案:

答案 0 :(得分:1)

您可以通过以下方式获取第二个参数:

preg_match_all("/'(.*?)'/", $script, $m);
echo $m[1][1];