如何利用正则表达式 获取<script> 标签中的内容
我想要利用curl进行模拟登录查询课表,目前已经成功,但是我想将课表数据写入到一个数组中,于是想要用正则表达式获取,查看页面源代码发现<table>标签中是一张空表,它是...
我想要利用curl 进行模拟登录 查询课表
,目前已经成功,但是我想将课表数据写入到一个数组中,于是想要用正则表达式获取,查看页面源代码发现<table>标签中是一张空表,它是
利用Javascript将内容填入表中的,所以获取<table>只能获取一张空表,课表的具体内容都在<script>中,
试了很久都没有成功,所以想求教一下怎么写?语言是PHP
<script>
// function CourseTable in TaskActivity.js
var table0 = new CourseTable(2015,70);
var unitCount = 10;
var index=0;
var activity=null;
activity = new
TaskActivity("12751","教师1(教授)","46722(18010168003)","课程1","6101","中地点
1","00000000011111111111111111000000000000000000000000000");
index =2*unitCount+0;
table0.activities[index][table0.activities[index].length]=activity;
index =2*unitCount+1;
table0.activities[index][table0.activities[index].length]=activity;
activity = new
TaskActivity("12563","教师2(助教)","44732(18010030004)","课程2","6082","地点2
","00000000001010101010101010000000000000000000000000000");
index =0*unitCount+0;
table0.activities[index][table0.activities[index].length]=activity;
index =0*unitCount+1;
table0.activities[index][table0.activities[index].length]=activity;
</script> 展开
,目前已经成功,但是我想将课表数据写入到一个数组中,于是想要用正则表达式获取,查看页面源代码发现<table>标签中是一张空表,它是
利用Javascript将内容填入表中的,所以获取<table>只能获取一张空表,课表的具体内容都在<script>中,
试了很久都没有成功,所以想求教一下怎么写?语言是PHP
<script>
// function CourseTable in TaskActivity.js
var table0 = new CourseTable(2015,70);
var unitCount = 10;
var index=0;
var activity=null;
activity = new
TaskActivity("12751","教师1(教授)","46722(18010168003)","课程1","6101","中地点
1","00000000011111111111111111000000000000000000000000000");
index =2*unitCount+0;
table0.activities[index][table0.activities[index].length]=activity;
index =2*unitCount+1;
table0.activities[index][table0.activities[index].length]=activity;
activity = new
TaskActivity("12563","教师2(助教)","44732(18010030004)","课程2","6082","地点2
","00000000001010101010101010000000000000000000000000000");
index =0*unitCount+0;
table0.activities[index][table0.activities[index].length]=activity;
index =0*unitCount+1;
table0.activities[index][table0.activities[index].length]=activity;
</script> 展开
1个回答
推荐于2016-01-01 · 知道合伙人互联网行家
关注
展开全部
不一定要正则的。字符串截取也行。
var str = '<a href="javascript:;" onclick="showWindow(\'dmo_vots\',\'plugin.php?id=votes:vote&appid=34&formhash=a45078c7\',\'get\',0)">投一票</a>';str = str.split('formhash=');str = str[1].split('\'');alert(str[0]);
var str = '<a href="javascript:;" onclick="showWindow(\'dmo_vots\',\'plugin.php?id=votes:vote&appid=34&formhash=a45078c7\',\'get\',0)">投一票</a>';str = str.split('formhash=');str = str[1].split('\'');alert(str[0]);
追问
我试了一下,单独的一条可以,比如这条TaskActivity("12751","教师1(教授)","46722(18010168003)","课程1","6101","中地点
1","00000000011111111111111111000000000000000000000000000");但是,数据有很多条,该怎么弄呢。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询