@@ -53,19 +53,21 @@ def getArticleData(url):
5353
5454 subtitleEle = article .find ("div" , class_ = "news-detail__excerpt" )
5555 if subtitleEle :
56- subtitle = subtitleEle .find ("p" ).get_text (strip = True )
57- subtitle = ("\n \n " + subtitle + "\n " ) if subtitle else ""
56+ pTag = subtitleEle .find ("p" )
57+ if pTag :
58+ subtitle = pTag .get_text (strip = True )
59+ subtitle = ("\n \n " + subtitle ) if subtitle else ""
5860
5961 descriptionContainers = article .find_all (
6062 "div" , class_ = "news-detail__main--text"
6163 )
6264 if descriptionContainers :
6365 pTag = descriptionContainers [0 ].find ("p" )
64- if not pTag :
65- desc += "\n " + pTag .get_text (strip = True )
66+ if pTag :
67+ desc += "\n \n " + pTag .get_text (strip = True )
6668
6769 if desc :
68- desc = " \n " + f"{ desc [:800 ]} ..." if len (desc ) > 800 else desc + " \n "
70+ desc = f"{ desc [:800 ]} ..." if len (desc ) > 800 else desc
6971
7072 caption = f"<b>{ title } </b>" f"{ subtitle } " f"{ desc } "
7173
@@ -146,12 +148,12 @@ def getArticleData(url):
146148 print ("✅ Message sended to telegram successfully" )
147149
148150 # Save to database:
149- print ("Save url to database - Saving..." )
150- save_to_database (
151- collection = realMadridArticlesCollection ,
152- data = {"article_url" : url , "source" : SOURCE_NAME },
153- )
154- print ("✅ Url saved to database successfully" )
151+ # print("Save url to database - Saving...")
152+ # save_to_database(
153+ # collection=realMadridArticlesCollection,
154+ # data={"article_url": url, "source": SOURCE_NAME},
155+ # )
156+ # print("✅ Url saved to database successfully")
155157
156158 print ("\n ✅ Script End - Exitting..." )
157159 except Exception as e :
0 commit comments