求一個PHP正則

來源:互聯網
上載者:User


24.143.198.188

:80

HTTP
250,890,890
United States

我想取出其IP和連接埠號碼;

主要是為了提取http://www.cnproxy.com/proxy1.html這個網頁上的Proxy 伺服器
24.143.198.188:80
37.57.20.143:3128
37.59.48.180:8118


回複討論(解決方案)

這不是簡但的正則就可完成的
比如
77.37.134.58HTTP188,907,922Russia
77.37.134.58 是伺服器ip
z+c+a+x 才是連接埠號碼,需要計算出真實值。
而這些 js 變數是在前面的

中賦值的

這不是簡但的正則就可完成的
比如
77.37.134.58HTTP188,907,922Russia
77.37.134.58 是伺服器ip
z+c+a+x 才是連接埠號碼,需要計算出真實值。
而這些 js 變數是在前面的

中賦值的 那我再看看,我是看到python中有實現這個功能,想試試php能做一個不。

def build_list_urls_6(page=3):page=page+1ret=[]for i in range(1,page):ret.append('http://www.cnproxy.com/proxy%(num)01d.html'%{'num':i})return retdef parse_page_6(html=''):    matches=re.findall(r'''        ([^&]+)                     #ip        ‌‍        \:([^<]+)                       #port                HTTP        [^<]+        ([^<]+)                #area        ''',html,re.VERBOSE)    ret=[]    for match in matches:        ip=match[0]        port=match[1]        type=-1          #該網站未提供Proxy 伺服器類型        area=match[2]        if indebug:print '6',ip,port,type,area        area=unicode(area, 'cp936')         area=area.encode('utf8')         ret.append([ip,port,type,area])return ret

但他的連接埠(port)取得也不對!

但他的連接埠(port)取得也不對! function parsePort($str)
{
$str = str_replace('document.write(":"', '', $str);
$str = str_replace(')', '', $str);
$str = str_replace('+x', '8', $str);
$str = str_replace('+f', '0', $str);
$str = str_replace('+z', '3', $str);
$str = str_replace('+c','1', $str);
$str = str_replace('+a','2', $str);
$str = str_replace('+i','3', $str);
$str = str_replace('+l','9', $str);
return ':'.$str;
}

謝謝版主大人,解決了

那恭喜你了

不過你還要注意檢查一下,每一頁的

是否都一樣

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.