import requests
from bs4 import BeautifulSoup
from docx import Document
# Define the URL of the web page to copy
url = 'https://www.example.com'
# Make a request to the web page
response = requests.get(url)
# Parse the HTML content of the page using BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')
# Create a new Word document object
doc = Document()
# Find all the content elements of the web page (e.g., paragraphs, headings, etc.)
content_elements = soup.find_all(['p', 'h1', 'h2', 'h3'])
# Iterate over the content elements and add them to the Word document
for element in content_elements:
doc.add_paragraph(element.get_text())
# Save the Word document
doc.save('page_content.docx')