Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- html = '<description><![CDATA[ <img alt="" height="250" width="250" src="https://ext.st.xxx/250s/6f9-f2198169675c.jpg"/>]]></description>'
- # Тег <img> напрямую в <description>, и при котором root.find('img') работает
- # html = '<description><img alt="" height="250" width="250" src="https://ext.st.xxx/250s/6f9-f2198169675c.jpg"/></description>'
- import re
- print(re.search('src="(.+?)"', html).group(1))
- print(re.findall('src="(.+?)"', html))
- print()
- from bs4 import BeautifulSoup
- root = BeautifulSoup(html, 'html.parser')
- print(root.find('img')) # Тут None, т.к. img находится в CDATA
Advertisement
RAW Paste Data
Copied
Advertisement