2011-12-01 146 views
-2

我需要AutoIt StringRegExp的幫助。AutoIt StringRegExp |保存到文件

我想從一個HTML文件中像這樣刮代理:

<td> 
<center> 
<a class="proxyList" href="http://whois.sc/77.79.9.229" target="_blank">77.79.9.229:80</a> 
<a class="proxyList" href="http://whois.sc/77.79.9.225" target="_blank">77.79.9.225:80</a> 
<a class="proxyList" href="http://whois.sc/89.202.194.17" 
target="_blank">89.202.194.17:8080</a> 
<a class="proxyList" href="http://whois.sc/46.20.35.78" target="_blank">46.20.35.78:8080</a> 
</td> 

這是我可怕的AutoIt代碼(它doesent工作:/):

ClipPut(_IEBodyReadHTML($oIE)) 

$ips = ClipGet() $array = StringRegExp($ips,' <center> * </td>', 3) 

$file = FileOpen("proxies.txt", 1) 

FileWrite($file, $array) 

FileClose($file) 

這就是我想要的:

proxies.txt: 
77.79.9.229:80 
77.79.9.225:80 
89.202.194.17:8080 
46.20.35.78:8080 

感謝您的幫助:)

回答

3

我不知道AutoIt的正則表達式的味道,但如果是類似PCRE,您正則表達式的意思是:

<center> : a space folowed by literal <center> 
*   : a space 0 or more times folowed by a space 
</td>  : literal </td> 

我不是很確定這就是你想要;-)

要捕捉什麼IP和端口,你應該這樣做:

(\d{1,3}(?:\.\d{1,3}){3}:\d{1,5}) 
+0

謝謝聽起來不錯:)是它的PCRE我現在嘗試它:) –

+0

它的作品:)不錯 –