title: find a hyperlink in Gmail body python 3
body: <p><strong>I am making a program to automatically read emails and click automatically a  hyperlink in that email body</strong>.</p>
  
  <p>A taxi company provides contractions from email. immediately need to click on link in email. </p>
  
  <p>I am using <strong>imaplib</strong> , <strong>selenium</strong> , <strong>re</strong> to code this.
  I successfully coded the login to email using imaplib and read mail.</p>
  
  <p>Now <strong>i need to get hyperlink from mail</strong>.(hyperlink text is confirm)
  code given below</p>
  
  <pre><code>import imaplib 
  import email
  
  mail = imaplib.IMAP4_SSL('imap.gmail.com')
  mail.login('xxxxxxxxxx@gmail.com', 'xxxxxxxx')
  mail.list()
  # Out: list of "folders" aka labels in gmail.
  mail.select("inbox") # connect to inbox.
  
  result, data = mail.search(None, "ALL")
  
  ids = data[0] # data is a list.
  id_list = ids.split() # ids is a space separated string
  latest_email_id = id_list[-1] # get the latest
  
  result, data = mail.fetch(latest_email_id, "(RFC822)") # fetch the email body (RFC822) for the given ID
  
  raw_email = data[0][1] # here's the body, which is raw text of the whole email
  # including headers and alternate payloads
  print(raw_email)
  </code></pre>