python - TypeError: expected string or bytes-like object -


i've written script parse html , print text content only. wanted ignore tags. program has problem. not sure is. please me.

enter image description here

import urllib.request import re bs4 import beautifulsoup url = "www.example.com"  def hi():     dep = urllib.request.urlopen(url)     soup = beautifulsoup(dep, 'html.parser')     link in soup.find_all('p', string=true):         result = re.sub(b'<.*?>', "", link)         print (result) hi()  

the website link.

i believe, have navigablestring in link variable.

force cast string like:

for link in soup.find_all('p', string=true):     result = re.sub(b'<.*?>', "", str(link))     print (result) 

Comments

Popular posts from this blog

ffmpeg h264_omx encoder - libomxcore.so missing. - Raspberry Pi Forums

Need simple timer/stopwatch sketch

Dtc compilation fails - Raspberry Pi Forums