Code: Select all
import pandas as pd
import requests
from bs4 import BeautifulSoup
# Provide the absolute path
file_path = r'D:\VS CODE\scrap_tool\Company_list-1.csv'
df = pd.read_csv(file_path)
print(df.head(5))
print(df.columns)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
}
def get_contact_number(url):
try:
# Fetch the website content
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers, timeout=10)
soup = BeautifulSoup(response.text, 'html.parser')
# Search for phone numbers using regex patterns
phone_numbers = set()
for text in soup.stripped_strings:
if '+91' in text or text.isdigit():
if len(text) >= 10 and len(text)