I have two different Python files. Each of them scraps some data from websites, and they print the data into a docx file. However, I want to compound them and print the all data to one single docx file. For example:

Headline from file1
Data from file1
Data from file1

Headline from file2
Data from file2
Data from file2

They should be in the same document, but I really couldn't figure it out.. I'm a total beginner, so can you show me how to do that? I would really appreciate it. Thanks in advance for all of your help.

Here are the codes:

code1:

```
from bs4 import BeautifulSoup
from docx import Document
from docx.shared import Pt
import requests

user_agent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.``3945.88 Safari/537.37"
url = "https://www.brookings.edu/events/"
data = requests.get(url, headers={"User-Agent": user_agent})
soup = BeautifulSoup(data.text, "lxml")

document = Document()

heading = document.add_heading().add_run("Brookings Institute")
heading.font.name = "Cambria"
heading.font.size = Pt(14)

events = soup.find_all("article", class_ = "archive-view archive-event event-standard-view past")
for event in events:
    event_name = event.find("h4", class_ = "title")
    link = event.find("a", class_ = "event-content")
    try:
        print(event_name.text)
        document.add_paragraph(event_name.text, style='List Bullet')
        print(link['href'])
        document.add_paragraph(link['href'])
    except:
        continue

document.save('demo.docx')

```

Code2:

```
from bs4 import BeautifulSoup
from docx import Document
from docx.shared import Pt
import requests
url = 'https://www.newamerica.org/api/event/?time_period=past&page_size=12&page=1&story_image_rendition=small'

r = requests.get(url)
data = r.json()

document = Document()

heading = document.add_heading().add_run("New America")
heading.font.name = "Cambria"
heading.font.size = Pt(14)

for i in data['results']:
    title = i['title']
    link = i['url']
    try:
        print(f'Title: {title}\nURL: {link}\n\n')
        document.add_paragraph({title}, style='List Bullet')
        document.add_paragraph({link}, style='List Bullet')
    except:
        continue

document.save('demo.docx')

```