title: In Python, how do I search an html webpage for a set of strings in text file?
body: <p>I'm trying to figure out a way to search an html webpage for a number of strings that I have written in a text file, each on its own line. The code I have so far is this:</p>
  
  <pre><code>def mangasearch():
      r = requests.get("https://www.mangaupdates.com/releases.html")
      soup = BeautifulSoup(r.text)
      if soup.find(text=re.compile(line)):
          print("New chapter found!")
          print("")
      else:
          print("No new chapters")
          print("")
  
  
  def textsearch():
      global line
      with open("manga.txt") as file:
          for line in file:
              print(line)
              mangasearch()
  </code></pre>
  
  <p>It's supposed to read manga.txt and search the webpage for each string separately, but it always returns "no new chapters". If I replace <code>if soup.find(text=re.compile(line)):</code> with <code>if soup.find(text=re.compile("An actual string")):</code> it works correctly, but for some reason it doesn't want to use the <code>line</code> variable. Any help would be appreciated!</p>