I have a list of 2500 gaming studios in Uk and I want to fetch the contact details of them using google . How can i proceed?
import requests
import re
from bs4 import BeautifulSoup
def extract_contact_info(url):
# Send a GET request to the URL
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
# Parse HTML content
soup = BeautifulSoup(response.text, 'html.parser')
# Extract text from the HTML
text = soup.get_text()
# Use regular expressions to find phone numbers, email addresses, and addresses
phone_numbers = re.findall(r'[+(]?[1-9][0-9 .-()]{8,}[0-9]', text)
email_addresses = re.findall(r'b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}b', text)
addresses = re.findall(r'bd{1,5}sw+sw+sw+sw+b', text) # Simple example, adjust as per your needs
return phone_numbers, email_addresses, addresses
else:
print("Failed to fetch the page. Status code:", response.status_code)
return [], [], []
Example usage
url = ‘https://3dnative.com/contact/’ # Replace with the URL of the website you want to extract contact info from
phone_numbers, email_addresses, addresses = extract_contact_info(url)
if phone_numbers:
print(“Phone Numbers:”)
for number in phone_numbers:
print(number)
if email_addresses:
print(“Email Addresses:”)
for email in email_addresses:
print(email)
if addresses:
print(“Addresses:”)
for address in addresses:
print(address)