Господа, помогите плз, написал такую штуку:
import re
from wiki_req import get_topic_page
def get_topic_text (topic):
html_content = get_topic_page(topic)
words = re.findall("[а-яА-Я\-]+", html_content)
text = " ".join(words)
return text
print(get_topic_text ("Москва"))
а он мне выдает такое
Traceback (most recent call last):
File "C:/Users/admin/PycharmProjects/helloworld/ООП/ООП4/index.py", line 10, in <module>
print(get_topic_text ("Москва"))
File "C:/Users/admin/PycharmProjects/helloworld/ООП/ООП4/index.py", line 6, in get_topic_text
words = re.findall("[а-яА-Я\-]+", html_content)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 223, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object
Помогите пожалуйста
вот тут исходный сам файл wiki_req
from requests import get
"""https://ru.wikipedia.org/wiki/Россия"""
def get_link(topic):
link = "https://ru.wikipedia.org/wiki/" + topic
return link
def get_topic_page (topic):
link = get_link(topic)
html_content = get(link).text
with open("new.html", "w", encoding="utf-8") as f:
f.write(html_content)
return True
print(get_topic_page ("биржа"))
@
, так ему придёт уведомление.