Extract emails from html using regex

前端 未结 3 1035
无人共我
无人共我 2021-01-22 20:25

I\'m trying to extract any jabber accounts (emails) using regex from this page.

I\'ve tried using regex:

\\w+@[\\w.-]+|\\{(?:\\w+, *)+\\w+\\}@[\\w.-]+
         


        
3条回答
  •  遥遥无期
    2021-01-22 21:21

    # -*- coding: utf-8 -*-
    s = '''
    ...YOUR HTML page source code HERE..........
    
    '''
    
    import re
    reobj = re.compile(r"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b", re.IGNORECASE)
    print re.findall(reobj, s.decode('utf-8'))
    

    Result

    [u'skypeman@jabbim.cz', u'sonics@creep.im', u'voxis_team@lsd-25.ru', u'voxis_team@lsd-25.ru', u'adhrann@jabbim.cz', u'jabberwocky@jabber.systemli.org']
    

提交回复
热议问题