Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- def search_web_for_phrase(url, target_phrase):
- try:
- # Send a GET request to the URL
- response = requests.get(url)
- # Check if the request was successful (status code 200)
- if response.status_code == 200:
- # Parse the HTML content of the page using BeautifulSoup
- soup = BeautifulSoup(response.text, 'html.parser')
- # Find all text content within the page
- page_text = soup.get_text()
- # Check if the target phrase exists in the page text
- if target_phrase in page_text:
- print(f"Found '{target_phrase}' on {url}")
- else:
- print(f"'{target_phrase}' not found on {url}")
- else:
- print(f"Failed to fetch {url}. Status code: {response.status_code}")
- except requests.RequestException as e:
- print(f"Error: {e}")
- # Example usage:
- url_to_scan = "https://www.addsitehere.com" # Replace with your desired URL
- phrase_to_find = "Your Phrase Here" # Replace with the phrase you want to search for
- search_web_for_phrase(url_to_scan, phrase_to_find)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement