【Lua正则表达式】解析匹配优酷电视剧集的下载地址用来批量下载
通常用iDown批量将要看的电视剧下载下来以后慢慢看,会用到批量下载。
例如西游记:http://www.soku.com/search_video/q_%E8%A5%BF%E6%B8%B8%E8%AE%B0
右键“查看网页源码”,找到有视频链接的代码处拷贝出来进行处理,去掉多余的字符只留下下载链接。
text = [[ <div class="mask"><div class="ico__loading_32"></div></div> <div class="panel_15"> <ul class="linkpanel panel_15" id="group1"> <li><a href='http://v.youku.com/v_show/id_XMzQzNTEwNDQ4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>1</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzNzQzMjYw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>2</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzNzY0OTAw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>3</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzNzk0Mjk2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>4</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzODI0ODcy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>5</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzODUxNTA4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>6</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzODc0MTIw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>7</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzODk3NTcy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>8</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTE3MzEy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>9</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTMzOTQw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>10</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTQ4Mjk2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>11</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTY2NzEy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>12</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTY3MDY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>13</a></li><li><a href='http://v.youku.com/v_show/id_XMzQzOTY3NjI4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>14</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3ODk4MDY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>15</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3OTE5NzY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>16</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3OTM3MTQ4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>17</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3OTUyNzMy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>18</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3OTYxOTQw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>19</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ3OTcwNjY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>20</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MjA1NTU2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>21</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MjUyOTE2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>22</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MjkwODY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>23</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MzIxMDI4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>24</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MzMzMTQw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>25</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MzM4MDM2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>26</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MzQyMjE2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>27</a></li><li><a href='http://v.youku.com/v_show/id_XMzQ4MzQ0NDMy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>28</a></li><li><a href='http://v.youku.com/v_show/id_XMzUxMDI0Mzc2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>29</a></li><li><a href='http://v.youku.com/v_show/id_XMzUxMDgxMzk2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>30</a></li> <li class="mhandle" title="显示全部"><span>······</span></li> <li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTE4NjY0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>31</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTQ4NzU2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>32</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTcxMzQ0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>33</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTg0OTA4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>34</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTg4NTM2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>35</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTkyNjA4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>36</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTk1OTA4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>37</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMTk4MzQ4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>38</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjAyNDg0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>39</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjAzNzAw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>40</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjExNzEy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>41</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjEzNTI4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>42</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjIyOTI0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>43</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUxMjI2NTY4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>44</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNTAyMjE2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>45</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNTI5MTAw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>46</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNTY1NTEy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>47</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNTk2ODAw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>48</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjE0NzQ0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>49</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjI2NjEy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>50</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjM0MTg4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>51</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjM3NTQ0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>52</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjQwMjgw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>53</a></li><li class="ex"><a href='http://v.youku.com/v_show/id_XMzUzNjQyNjI0.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>54</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjQ0ODcy.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>55</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjQ2NTc2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>56</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjQ4NDI4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>57</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjQ5NjY4.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>58</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjUxMzU2.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>59</a></li><li class="xe"><a href='http://v.youku.com/v_show/id_XMzUzNjUzMzQw.html' site='youku' onclick='sokuClickStat(this, true);' _log_type='2' _log_ct='1' _log_pos=1 _log_directpos='4' target='_blank'>60</a></li> <li class="handle"><span>全部</span></li> ]]; s = ''; for url in string.gmatch(text,"(http[^%z]-.html)") do s = s..url..'\n'; end msgbox(s);
结果:
http://v.youku.com/v_show/id_XMzQzNTEwNDQ4.html http://v.youku.com/v_show/id_XMzQzNzQzMjYw.html http://v.youku.com/v_show/id_XMzQzNzY0OTAw.html http://v.youku.com/v_show/id_XMzQzNzk0Mjk2.html http://v.youku.com/v_show/id_XMzQzODI0ODcy.html http://v.youku.com/v_show/id_XMzQzODUxNTA4.html http://v.youku.com/v_show/id_XMzQzODc0MTIw.html http://v.youku.com/v_show/id_XMzQzODk3NTcy.html http://v.youku.com/v_show/id_XMzQzOTE3MzEy.html http://v.youku.com/v_show/id_XMzQzOTMzOTQw.html http://v.youku.com/v_show/id_XMzQzOTQ4Mjk2.html http://v.youku.com/v_show/id_XMzQzOTY2NzEy.html http://v.youku.com/v_show/id_XMzQzOTY3MDY0.html http://v.youku.com/v_show/id_XMzQzOTY3NjI4.html http://v.youku.com/v_show/id_XMzQ3ODk4MDY0.html http://v.youku.com/v_show/id_XMzQ3OTE5NzY0.html http://v.youku.com/v_show/id_XMzQ3OTM3MTQ4.html http://v.youku.com/v_show/id_XMzQ3OTUyNzMy.html http://v.youku.com/v_show/id_XMzQ3OTYxOTQw.html http://v.youku.com/v_show/id_XMzQ3OTcwNjY0.html http://v.youku.com/v_show/id_XMzQ4MjA1NTU2.html http://v.youku.com/v_show/id_XMzQ4MjUyOTE2.html http://v.youku.com/v_show/id_XMzQ4MjkwODY0.html http://v.youku.com/v_show/id_XMzQ4MzIxMDI4.html http://v.youku.com/v_show/id_XMzQ4MzMzMTQw.html http://v.youku.com/v_show/id_XMzQ4MzM4MDM2.html http://v.youku.com/v_show/id_XMzQ4MzQyMjE2.html http://v.youku.com/v_show/id_XMzQ4MzQ0NDMy.html http://v.youku.com/v_show/id_XMzUxMDI0Mzc2.html http://v.youku.com/v_show/id_XMzUxMDgxMzk2.html http://v.youku.com/v_show/id_XMzUxMTE4NjY0.html http://v.youku.com/v_show/id_XMzUxMTQ4NzU2.html http://v.youku.com/v_show/id_XMzUxMTcxMzQ0.html http://v.youku.com/v_show/id_XMzUxMTg0OTA4.html http://v.youku.com/v_show/id_XMzUxMTg4NTM2.html http://v.youku.com/v_show/id_XMzUxMTkyNjA4.html http://v.youku.com/v_show/id_XMzUxMTk1OTA4.html http://v.youku.com/v_show/id_XMzUxMTk4MzQ4.html http://v.youku.com/v_show/id_XMzUxMjAyNDg0.html http://v.youku.com/v_show/id_XMzUxMjAzNzAw.html http://v.youku.com/v_show/id_XMzUxMjExNzEy.html http://v.youku.com/v_show/id_XMzUxMjEzNTI4.html http://v.youku.com/v_show/id_XMzUxMjIyOTI0.html http://v.youku.com/v_show/id_XMzUxMjI2NTY4.html http://v.youku.com/v_show/id_XMzUzNTAyMjE2.html http://v.youku.com/v_show/id_XMzUzNTI5MTAw.html http://v.youku.com/v_show/id_XMzUzNTY1NTEy.html http://v.youku.com/v_show/id_XMzUzNTk2ODAw.html http://v.youku.com/v_show/id_XMzUzNjE0NzQ0.html http://v.youku.com/v_show/id_XMzUzNjI2NjEy.html http://v.youku.com/v_show/id_XMzUzNjM0MTg4.html http://v.youku.com/v_show/id_XMzUzNjM3NTQ0.html http://v.youku.com/v_show/id_XMzUzNjQwMjgw.html http://v.youku.com/v_show/id_XMzUzNjQyNjI0.html http://v.youku.com/v_show/id_XMzUzNjQ0ODcy.html http://v.youku.com/v_show/id_XMzUzNjQ2NTc2.html http://v.youku.com/v_show/id_XMzUzNjQ4NDI4.html http://v.youku.com/v_show/id_XMzUzNjQ5NjY4.html http://v.youku.com/v_show/id_XMzUzNjUxMzU2.html http://v.youku.com/v_show/id_XMzUzNjUzMzQw.html
直接复制粘贴到iDown中进行批量下载即可。