I am making a notification system which sends emails with a html table which has images.
the images shows up fine in the actual page. I am grabbing the table source with selenium (changing all relative paths to full paths)
for attr in driver.find_elements_by_xpath('//table[@id="mainTable"]/tbody/tr[contains(@id, "cell_")]'):
#gettin the image link
imgattr = attr.find_element_by_xpath('.//td[4]/a[1]/img[1]')
imglink = imgattr.get_attribute('src')
#changing to full path and setting that with javascript
driver.execute_script('arguments[0].setAttribute("src","{}");'.format(urljoin(root_url, imglink)), imgattr)
driver.execute_script('arguments[0].setAttribute("width","{}");'.format('72'), imgattr)
driver.execute_script('arguments[0].setAttribute("height","{}");'.format('54'), imgattr)
#getting the element (table) again
#with image links changed to full path
elem = driver.find_element_by_xpath('//table[@id="mainTable"]')
resp = elem.get_attribute('innerHTML')
now i am using mailgun api to send a email
r = requests.post(
"https://api.mailgun.net/version/my domain name/messages",
auth=("api", "my api key"),
data={"from": "mailgun@mydomain",
"to": ["recipient1@gmail.com", "recipient2@gmail.com"],
"subject": "random subject",
"html": resp})
email gets sent no issues but the images dont how, their links change when sent in email
example Actual Page
Sent email inspect element, links change from source to a blank one
Basically the image changes from this:
<img src="https://p3.aleado.com/pic/?system=auto&date=2019-11-07&auct=243&bid=70048&number=1&w=72" load_src="https://p3.aleado.com/pic/?system=auto&date=2019-11-07&auct=243&bid=70048&number=1&w=72" border="0" name="img_preview" width="72">
To this:
<img src="https://ci6.googleusercontent.com/proxy/qQR9p1-B2oWM3V-bVJssDVajsvZN9irPqHctNMUr6jTsgKmuZFP30fcTB54a-wtpM_H6rL0K_Fz7huR4oMPVTISpvE7XSJkwwFbFMZc6B2yVviL28WMGzAXGzlso8RHgGTjxGwqGS7_XAQ=s0-d-e1-ft#https://p3.aleado.com/pic/?system=auto&date=2019-11-07&auct=243&bid=70048&number=1&w=72" name="m_-9099380790990105554_img_preview" class="CToWUd" width="72" border="0">
I have tried Base64 but Gmail doesn't support it and show blanks in its place
What am i doing wrong here and how can i embed those links?
any suggestions would be helpful.
Thanks in advance