I'm a beginner on regex of python
target test.php code:
<html>
<head></head>
<body>
<a href="www.google.com">[email protected]</a>
<div>[email protected]</div>
[email protected]
[email protected]
</body>
</html>
This is my code:
import requests,re
email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)')
res = requests.get("http://127.0.0.1/test.php")
a = email_pattern.findall(res.text)
print a
The result :
[(u'[email protected]', u'com.'), (u'[email protected]', u'com.'), (u'[email protected]', u'gmail.'), (u'[email protected]', u'test.')]
But I want the result like:
[[email protected], [email protected], [email protected], [email protected]]
What wrong in my pattern or code ?
Why the result is multiple list containse extra com , gmail , test ?
Thank you solve my doubts !
'([\w\-\.]+@(?:\w[\w\-]+\.)+[\w\-]+)'