-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.py
More file actions
26 lines (20 loc) · 691 Bytes
/
Copy pathprogram.py
File metadata and controls
26 lines (20 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from bs4 import BeautifulSoup
import requests
from collections import Counter
import tempfile
def main():
r = requests.get("https://en.wikipedia.org/wiki/Intuitive_Machines_Nova-C")
with tempfile.NamedTemporaryFile(delete=False) as temp:
temp.write(r.content)
temp.flush()
temp_filename = temp.name
with open(temp_filename, "r") as file:
soup = BeautifulSoup(file, "html.parser")
words = Counter()
for paragraph in soup.find_all("p"):
for word in paragraph.text.split():
if len(word) > 3:
words[word] += 1
print(words.most_common(10))
if __name__ == "__main__":
main()