我正在建立一个通知系统,该系统将通过带有图像的html表发送电子邮件。
图像在实际页面中显示良好。 我正在用硒抓取表源(将所有相对路径更改为完整路径)
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')
现在我正在使用mailgun api发送电子邮件
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})
电子邮件没有发送任何问题,但是图像却没有发送,当通过电子邮件发送时,它们的链接也会改变 示例实际页面
基本上,图像由此改变:
<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">
对此:
<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">
我尝试使用Base64,但是Gmail不支持它,并在其位置显示空白
我在这里做错什么,如何嵌入这些链接?
任何建议都会有所帮助。
预先感谢