Reputation: 433
I have the following code:
soup = BeautifulSoup(content, "html.parser")
block = soup.select('.meta-info a')
I need to get all links in block .meta_info
After I try to get all text of links from array block
, only that have email address as text link.
I mean:
<a href="">Bla bla [email protected]</a>
How can I get it?
I tried as:
for item in block:
email_par = emailFromString(item.text)
if email_par[0]:
pass
But it works not stable
Upvotes: 0
Views: 210
Reputation: 97
this link might be helpful css select with regex
if you still cant figure it out try this, make sure you have the latest version of BeautifulSoup
import re
soup = BeautifulSoup(content, "html.parser")
block = soup.select('.meta-info a')
emails = block.find_all(text=re.compile('.*@.*\.com'))
now you can iterate over it and extract the text from each of the links
Upvotes: 1