我想从一个网站上提取包含两个特殊的波斯语单词"توافق"或"توافقی"的广告.我正在用BeautifulSoup和拆分汤中的内容来寻找有我特殊词汇的广告,但我的代码不起作用,你能帮帮我吗? 以下是我的简单代码:
import requests
from bs4 import BeautifulSoup
r = requests.get("https://divar.ir/s/tehran")
soup = BeautifulSoup(r.text, "html.parser")
results = soup.find_all("div", attrs={"class": "kt-post-card__body"})
for content in results:
words = content.split()
if words == "توافقی" or words == "توافق":
print(content)