title: #beautifulsoup How to export each article into different word file?
body: <p>How to export each article into different word file using beautifulsoup?</p>
  <p>I am trying to scrap all  the articles and export them one by one into different word files</p>
  <p>suppose if there are 1000 articles i want 1000 word files</p>
  <p>here is my code</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  import time
  
  #to loop over all 199 pages
  for i in range(1,199):
      URL = &quot;https://trumpwhitehouse.archives.gov/remarks/page/&quot;
  
      r = requests.get(URL+str(i))
      soup = BeautifulSoup(r.content,'lxml')
  
      #to get all the links from the first page of news headlines
      links=[]
      for news in soup.findAll('h2', class_='briefing-statement__title'):
          links.append(news.a['href'])
      
      #followed the link from the first page and extract article text
      for link in links:
          page=requests.get(link)
          sp=BeautifulSoup(page.text,&quot;lxml&quot;)
          article=sp.find(&quot;div&quot;,class_=&quot;page-content&quot;).find_all(&quot;p&quot;)
          for d in article:
              print(d.get_text())
      
      #sleep time to 3 seconds to overcome blocking
      time.sleep(3)     
  </code></pre>