html页面中定义如下javascript函数:

function tvod_check(contentid,ContentName,leefocus,starttime) { tvodauthform.ContentID.value = contentid; tvodauthform.ContentName.value = ContentName; tvodauthform.contentCode.value = contentid; tvodauthform.programid.value = contentid; tvodauthform.channelid.value="ch09070116351052478046"; tvodauthform.leefocus.value = leefocus; tvodauthform.starttime.value = starttime; tvodauthform.submit(); }
同时,有表单:

<form name="tvodauthform" action="tvlookback_preauth.jsp" method="get"> <input name="ContentID" type="hidden" value=""> <input name="ContentType" type="hidden" value="4"> <input name="CategoryID" type="hidden" value="4200"> <input name="FatherContent" type="hidden" value="ch09070116351052478046"> <input name="ContentName" type="hidden" value=""> <input name="leefocus" type="hidden" value=""> <input name="contentCode" type="hidden" value=""> <input name="channelid" type="hidden" value=""/> <input name="columnid" type="hidden" value="4200"> <input name="programid" type="hidden" value=""> <input name="starttime" type="hidden" value=""> <input name="destpage" type="hidden" value="1"> </form>
js调用形式:

<div style="left:117; top:166;width:517;height:39; position:absolute" align="left"> <a href="javascript:tvod_check('00000000040003541459','卡通大本营','g2l2','20120918073000')" name="g2l2" onfocus="scrollText('div2','','#FFFFFF','false');" onblur="scrollStop('div2','卡通大本营','#FFFFFF','false')" > <img src="images/btn_trans.gif" alt="" width="517" height="39" border="0"/> </a> </div>
用htmlunit执行对js调用:

String hrefValue = "javascript:tvod_check('00000000040003541459','卡通大本营','g2l2','20120918073000')";
String url = execJavascript(hrefValue, htmlPage, webClient);
执行日志:

1: 61615 [Thread-1]errCnt=0 connTimeoutCnt=0 readTimeoutCnt=0 connTime=0 readTime=461 2: 61615 [Thread-1]evaluate EPG workload: 2 =(2*0.2+2*0.35+1*0.2+4*0.2+0*0.05) 3: 69182 [pool-2-thread-1]Firing Event beforeunload (Current Target: HTMLElement for HtmlHtml[<html>]); 4: 69182 [pool-2-thread-1] Load response for GET http://58.223.255.211:8080/iptvepg/frame68/tvlookback_preauth.jsp?ContentID=00000000040003541459&ContentType=4&CategoryID=4200&FatherContent=ch09070116351052478046&ContentName=%BF%A8%CD%A8%B4%F3%B1%BE%D3%AA&leefocus=g2l2&contentCode=00000000040003541459&channelid=ch09070116351052478046&columnid=4200&programid=00000000040003541459&starttime=20120918073000&destpage=1 5: 69182 [pool-2-thread-1]Connection request: [route: {}->http://58.223.255.211:8080][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20] 6: 69198 [pool-2-thread-1]Connection leased: [id: 2][route: {}->http://58.223.255.211:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20] 7: 69198 [pool-2-thread-1]Stale connection check 8: 69198 [pool-2-thread-1]Stale connection detected 9: 69198 [pool-2-thread-1]Connection 0.0.0.0:51736<->58.223.255.211:8080 closed 10: 69198 [pool-2-thread-1]Connecting to 58.223.255.211:8080 11: 69215 [pool-2-thread-1]CookieSpec selected: mine 12: 69215 [pool-2-thread-1]Cookie [version: 0][name: JSESSIONID][value: 9C6F6183AA6C985351E23CDBA84777FF][domain: 58.223.255.211][path: /iptvepg][expiry: null] match [58.223.255.211:8080/iptvepg/frame68/tvlookback_preauth.jsp] 13: 69215 [pool-2-thread-1]Auth cache not set in the context 14: 69215 [pool-2-thread-1]Target auth state: UNCHALLENGED 15: 69215 [pool-2-thread-1]Proxy auth state: UNCHALLENGED 16: 69215 [pool-2-thread-1]Attempt 1 to execute request 17: 69215 [pool-2-thread-1] Sending request : GET /iptvepg/frame68/tvlookback_preauth.jsp?ContentID=00000000040003541459&ContentType=4&CategoryID=4200&FatherContent=ch09070116351052478046&ContentName=%BF%A8%CD%A8%B4%F3%B1%BE%D3%AA&leefocus=g2l2&contentCode=00000000040003541459&channelid=ch09070116351052478046&columnid=4200&programid=00000000040003541459&starttime=20120918073000&destpage=1 HTTP/1.1 18: 69215 [pool-2-thread-1]>> " GET /iptvepg/frame68/tvlookback_preauth.jsp?ContentID=00000000040003541459&ContentType=4&CategoryID=4200&FatherContent=ch09070116351052478046&ContentName=%BF%A8%CD%A8%B4%F3%B1%BE%D3%AA&leefocus=g2l2&contentCode=00000000040003541459&channelid=ch09070116351052478046&columnid=4200&programid=00000000040003541459&starttime=20120918073000&destpage=1 HTTP/1.1[\r][\n]" 19: 69215 [pool-2-thread-1]>> "Host: 58.223.255.211:8080[\r][\n]" 20: 69215 [pool-2-thread-1]>> "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.3) Gecko/20100101 Firefox/10.0.3[\r][\n]" 21: 69215 [pool-2-thread-1]>> "Accept-Language: en-us[\r][\n]" 22: 69215 [pool-2-thread-1]>> "Referer: http://58.223.255.211:8080/iptvepg/frame68/tvlookback_show.jsp?authtype=tvodpage&columnid=4200&channelid=ch09070116351052478046&rowid=20&date=2012.09.18&leefocus=llinker4020[\r][\n]" 23: 69215 [pool-2-thread-1]>> "Accept-Encoding: gzip, deflate[\r][\n]" 24: 69215 [pool-2-thread-1]>> "Accept: */*[\r][\n]" 25: 69215 [pool-2-thread-1]>> "Connection: Keep-Alive[\r][\n]" 26: 69215 [pool-2-thread-1]>> "Cookie: JSESSIONID=9C6F6183AA6C985351E23CDBA84777FF[\r][\n]" 27: 69215 [pool-2-thread-1]>> "[\r][\n]" 28: 69215 [pool-2-thread-1]>> GET /iptvepg/frame68/tvlookback_preauth.jsp?ContentID=00000000040003541459&ContentType=4&CategoryID=4200&FatherContent=ch09070116351052478046&ContentName=%BF%A8%CD%A8%B4%F3%B1%BE%D3%AA&leefocus=g2l2&contentCode=00000000040003541459&channelid=ch09070116351052478046&columnid=4200&programid=00000000040003541459&starttime=20120918073000&destpage=1 HTTP/1.1 29: 69215 [pool-2-thread-1]>> Host: 58.223.255.211:8080 30: 69215 [pool-2-thread-1]>> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.3) Gecko/20100101 Firefox/10.0.3 31: 69215 [pool-2-thread-1]>> Accept-Language: en-us 32: 69230 [pool-2-thread-1]>> Referer: http://58.223.255.211:8080/iptvepg/frame68/tvlookback_show.jsp?authtype=tvodpage&columnid=4200&channelid=ch09070116351052478046&rowid=20&date=2012.09.18&leefocus=llinker4020 33: 69230 [pool-2-thread-1]>> Accept-Encoding: gzip, deflate 34: 69230 [pool-2-thread-1]>> Accept: */* 35: 69230 [pool-2-thread-1]>> Connection: Keep-Alive 36: 69230 [pool-2-thread-1]>> Cookie: JSESSIONID=9C6F6183AA6C985351E23CDBA84777FF 37: 69230 [pool-2-thread-1]<< " HTTP/1.1 302 Moved Temporarily [\r][\n]" 38: 69230 [pool-2-thread-1]<< "Server: Apache-Coyote/1.1[\r][\n]" 39: 69246 [pool-2-thread-1]<< " Location : http://58.223.255.211:8080/iptvepg/frame68/control_tvodchannel_playafterad.jsp?columnid=4200&programid=00000000040003541459&channelid=ch09070116351052478046&contentCode=00000000040003541459&leefocus=g2l2[\r][\n]" 40: 69246 [pool-2-thread-1]<< "Content-Type: text/html;charset=GBK[\r][\n]" 41: 69246 [pool-2-thread-1]<< "Content-Length: 0[\r][\n]" 42: 69246 [pool-2-thread-1]<< "Date: Tue, 18 Sep 2012 04:15:19 GMT[\r][\n]" 43: 69246 [pool-2-thread-1]<< "[\r][\n]" 44: 69246 [pool-2-thread-1]Receiving response: HTTP/1.1 302 Moved Temporarily 45: 69246 [pool-2-thread-1]<< HTTP/1.1 302 Moved Temporarily 46: 69246 [pool-2-thread-1]<< Server: Apache-Coyote/1.1 47: 69246 [pool-2-thread-1]<< Location: http://58.223.255.211:8080/iptvepg/frame68/control_tvodchannel_playafterad.jsp?columnid=4200&programid=00000000040003541459&channelid=ch09070116351052478046&contentCode=00000000040003541459&leefocus=g2l2 48: 69246 [pool-2-thread-1]<< Content-Type: text/html;charset=GBK 49: 69246 [pool-2-thread-1]<< Content-Length: 0 50: 69246 [pool-2-thread-1]<< Date: Tue, 18 Sep 2012 04:15:19 GMT 51: 69246 [pool-2-thread-1]Connection can be kept alive indefinitely 52: 69246 [pool-2-thread-1]Connection [id: 2][route: {}->http://58.223.255.211:8080] can be kept alive indefinitely 53: 69246 [pool-2-thread-1]Connection released: [id: 2][route: {}->http://58.223.255.211:8080][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20] 54: 69246 [pool-2-thread-1]http return code is : 302 55: 69246 [pool-2-thread-1]url is : http://58.223.255.211:8080/iptvepg/frame68/tvlookback_preauth.jsp?ContentID=00000000040003541459&ContentType=4&CategoryID=4200&FatherContent=ch09070116351052478046&ContentName=%BF%A8%CD%A8%B4%F3%B1%BE%D3%AA&leefocus=g2l2&contentCode=00000000040003541459&channelid=ch09070116351052478046&columnid=4200&programid=00000000040003541459&starttime=20120918073000&destpage=1
执行该js,首先提交一表单,服务器返回第4行的url,down这个url,服务器给出了39行跳转地址(302 move),就是需要跳转到的最终地址。