此应用程序将在网站上运行并查找所有电子邮件并将其返回。
def testEmails(url):
'Test the emails() function'
email = ''
content = urlopen(url).read().decode()
pattern='[A-Za-z0-9_.]+\@[A-Za-z0-9_.]+\.'
for attr in content:
if attr[0] == 'href':
print(attr)
email+='{} '.format(attr)
emails = re.findall(pattern,email)
return emails
我一直收到一个空白字符串有人知道为什么吗?
编辑:
这是我当前的代码:
def emails(content):
'return list of email addresses contained in string content'
email = []
content = urlopen(url).read().decode()
pattern='[A-Za-z0-9_.]+\@[A-Za-z0-9_.]+\....'
email.append(re.findall(pattern,content))
print(email)
但由于某种原因,我得到:
[['somePERSON@university.ca"']]
代替 :
['somePERSON@university.ca']