Advertisement
NiktorTheNat

Cerca parola su pagine web

Mar 26th, 2023
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | Source Code | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests
  3.  
  4. parola="elettrico"
  5.  
  6. sito=["http://www.ansa.it","http://www.repubblica.it","http://www.ilgiornale.it"]
  7.  
  8. for p in sito:
  9.     print("Dal sito ",p," ho trovato:")
  10.     pagina=requests.get(p)
  11.     web=BeautifulSoup(pagina.content,"html.parser")
  12.     testo=web.get_text()
  13.     x=testo.split("\n")
  14.     for r in x:
  15.         if parola.lower() in r.lower():
  16.             print(r)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement