Advertisement
Guest User

Untitled

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