update scraper: sorted list first, then distinct set
This commit is contained in:
parent
afff26d65f
commit
c46d9a39a6
1 changed files with 8 additions and 2 deletions
|
|
@ -120,15 +120,21 @@ Then check your answers below.
|
|||
# strip tags, split on whitespace, find un* words
|
||||
text = re.sub(r"<[^>]+>", " ", html)
|
||||
words = text.split()
|
||||
un_words = sorted(set(
|
||||
un_words = sorted(
|
||||
w.strip(".,;:!?\"'()[]").lower()
|
||||
for w in words
|
||||
if w.lower().startswith("un")
|
||||
))
|
||||
)
|
||||
|
||||
print(f"all occurrences ({len(un_words)}):")
|
||||
for word in un_words:
|
||||
print(word)
|
||||
|
||||
distinct = sorted(set(un_words))
|
||||
print(f"\ndistinct words ({len(distinct)}):")
|
||||
for word in distinct:
|
||||
print(word)
|
||||
|
||||
|
|
||||
|
||||
**Define each word you find. Write your definitions before clicking the answer sheet.**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue