I am trying to save the results of a BeatifoulSoup
iteration that extract/parse text from a Wikipedia URL to a text file. I have not been successful creating the text file and adding text while I am iterating on my loop to parse sentences.
I would like to send the output of my code to a Text File. Printing to the screen works fine. Hope you can guide me here.
import requests
import string
from bs4 import BeautifulSoup
url_to_text = "https://en.wikipedia.org/wiki/Santiago"
url_open = requests.get(url_to_text)
soup = BeautifulSoup(url_open.content,'html.parser')
for i in range(1,50):
doc_text = print((soup('p')[i].text))