import requests
from bs4 import BeautifulSoup
import time
url = 'https://www.siteurl.com' # istek gönderilecek site adresi
last_id = '' # son başlık id'si
while True:
response = requests.get(url) # siteye istek gönderilir
soup = BeautifulSoup(response.text, 'html.parser')
titles = soup.find_all('tr', {'class': 'searchResultsItem'}) # başlıklar bulma
current_id = titles[-1]['data-id'] # en son başlık id
if last_id != current_id:
# son başlık değişmişse bildirim
print('Yeni başlık:', titles[-1].text.strip())
last_id = current_id
time.sleep(60) # istek gonderme suresidir gelen başlıkları metin belgesinde tutmak için ise ;
with open('basliklar.txt', 'a', encoding='utf-8') as f:
f.write(titles[-1].text.strip() + '\n')"Son başlığı tutmak için > last_id değişkeni"
File "C:UsersUserPycharmProjectspythonProjectmain.p y", line 16
print('Yeni başlık:', titles[-1].text.strip())
^
IndentationError: expected an indented block after 'if' statement on line 14
Process finished with exit code 1
Bu hatayı verdi hocam.