Author name: Poojitha Sepuri

Scrap a webpage site title using Python

Scrap a webpage site title using Python   Description: To scrap a webpage title first we need to have some libraries installed. Libraries like ‘request’ and ‘BeautifulSoup’ can be used to scrap the title. Implementation: import requests from bs4 import BeautifukSoup def get_webpage_title(url): try: response = requests.get(url) response.raise_for_status() soup = BeautifulSoup(response.content, ‘html.parser’) title = soup,title.string …

Scrap a webpage site title using Python Read More »

Count special characters in a string in Python

Description: To count a special characters in a string in python, we can use a string method “Regular expression”. In this ‘re’ special characters can be defined all the non-alphanumeric characters in the string. Using Regular Expression:import redef count_special_characters(s): special_characters_pattern = r'[^a-zA-Z0-9\s]’ special_characters = re.findall(special_character_pattern, s) return len(special_characters)input_string = “Hi, hello, Welcome! to @1year”count = …

Count special characters in a string in Python Read More »

Scroll to Top