I'm writing a basic webscraping code, which basically will get the date and title of a post and, if the date >= a date stored in a SQL db and the title != from a title also stored in the DB, then do some stuff.
I'm getting a syntax error when executing it. Here's the code:
for i in web_results:
py_newsdate = datetime.strptime(i.find('div', attrs={'class': "infoItem"}).find_all('p')[0].getText()[6:], '%d/%m/%Y')
py_newstitle = i.find('h3').find('a')['title']
if (py_newsdate < sql_latest[0][0] or py_newstitle == sql_latest[0][1]):
else:
py_newslink = i.find('h3').find('a')['href']
web_results_final.append([py_newsdate, py_newstitle, py_newslink])
print(web_results_final)
And here's the error:
File "searcher", line 37
else:
^
IndentationError: expected an indented block
I know the blocks have to be properly idented, but I'm thinking the problem may be on this "empty" if.
Thanks.
ifblock. Add at least a comment line orpass!