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.
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
Post a Comment