我有selenium beautifulsoup自动化脚本,可以使用应用程序密码访问域电子邮件,如outlook、gmail、aol、yahoo ...。
我想从电子邮件正文中提取(设备 IMEI 号码:)和(请求号码:)。
<br>
<br>
<b>Device IMEI number:</b>
<span style="color: #1D2329 !important; text-decoration:none;">
<a style="color: #1D2329;font-family:AleckSansfont-regular, Arial, Helvetica, sans-serif; text-decoration:none;">
353779334398833</a>
</span>
<br>
<b>Request number:</b>
<span style="color: #1D2329 !important; text-decoration:none;">
<a style="color: #1D2329;font-family:AleckSansfont-regular, Arial, Helvetica, sans-serif; text-decoration:none;">
NUL836822403006</a>
</span>
这应该有效:
美丽的汤
imei = soup.find('b', string='Device IMEI number:').find_next_sibling('span').get_text(strip=True)
request_number = soup.find('b', string='Request number:').find_next_sibling('span').get_text(strip=True)
硒
imei = driver.find_element(By.XPATH, '//b[text()="Device IMEI number:"]/following-sibling::span[1]/a').text
request_number = driver.find_element(By.XPATH, '//b[text()="Request number:"]/following-sibling::span[1]/a').text