Feb-26-2018, 11:35 PM
(This post was last modified: Feb-26-2018, 11:35 PM by digitalmatic7.)
Random example:
import requests
from bs4 import BeautifulSoup
import re
scrape = requests.get('http://www.seacoastonline.com/news/20171113/lets-not-let-politics-divide-us', headers={"user-agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"})
html = scrape.content
soup = BeautifulSoup(html, 'html.parser')
'''
if you search manually in the source (soup) you can find the string "houzz page"
but when when I use find_all, it returns nothing
'''
# print(soup)
comment_search = soup.body.find_all(string=re.compile("houzz page", re.IGNORECASE))
if len(comment_search) > 0:
print("houzz found")
else:
print("houzz not found")Also is my technique ok for returning the results (if len > 0)?
