Answer the question
In order to leave comments, you need to log in
How to parse large text into a string?
Good day, toasters)
And I'm interested in such a question that I've been struggling with for 3 days and I can't overcome it.
There is the following code:
def get_html(url):
html = requests.get(url)
return html.text
def get_descriptions(html):
description = ''
soup = bs(html, 'lxml')
description = soup.find('div', class_='item-description').text
return description
file_desc = open('file.txt', 'a')
url = 'Какой-то сайт'
html = get_html(url)
result_descriptions = str(get_descriptions(html)).replace('\n', ' ').replace('@', '')
file_desc.writelines('{}\n'.format(result_descriptions))
file_desc.close()
file_desc.writelines('{}\n'.format(result_descriptions[0:450]))
Answer the question
In order to leave comments, you need to log in
On Habré there is an article Unicode for Dummies
Must read for all pythonists and not only
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question