using the following code, i'm unable to break from the loop:
import requests
from bs4 import BeautifulSoup
link = "http://www.wuxiaworld.com/"
html = requests.get(link)
soup = BeautifulSoup(html.content, "html.parser")
all_aside = soup.find_all("aside", id="recent-posts-2")
for aside in all_aside:
for li in aside.find_all("li"):
for a in li.find_all("a"):
if "ATG" in a.text:
print(a.text)
break
i wanted to make a script that would notify me in case of the release of a new chapter of a story. I've just began making it but i got stuck here (it prints all the new releases containing the string "ATG" within the recent posts).
I made some research and found out that i should break of all the loops, yet when i try this bit of code, nothing gets printed to the console:
import requests
from bs4 import BeautifulSoup
link = "http://www.wuxiaworld.com/"
html = requests.get(link)
soup = BeautifulSoup(html.content, "html.parser")
all_aside = soup.find_all("aside", id="recent-posts-2")
for aside in all_aside:
for li in aside.find_all("li"):
for a in li.find_all("a"):
if "ATG" in a.text:
print(a.text)
break
break
break
Thank you.