import requests
from bs4 import BeautifulSoup
import cloudscraper
from pathlib import Path
def fiveLetterWordScrapper():
pageNum = 1
while pageNum != 51:
scraper = cloudscraper.CloudScraper()
page = scraper.get('https://www.thewordfinder.com/wordlist/5-letter-words/?dir=ascending&field=word&pg=' + str(pageNum) + '&size=5')
soup = BeautifulSoup(page.content, 'html.parser')
findWords = soup.find('ul', class_ = 'clearfix')
arrWordList = [x.get_text().strip()[0:5] for x in findWords if any(x.get_text().strip())]# the line that gives the error
with open(Path.cwd()/ 'fiveWordList.txt', 'a') as wordList:
for word in arrWordList:
wordList.write(word.lower() + 'n')
pageNum += 1
fiveLetterWordScrapper()
I had a script which goes through a website and practically finds all the 5 letter words that exist and puts it into a txt file. This script was working completely fine about two weeks ago as I ran it and it worked as intended, but now when I try to run the program it returns a “TypeError: ‘NoneType’ object is not iterable.”
I don’t think I changed anything about the code from when it first worked so I do not understand why it now gives a error when I try to run it.