-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebscraper.py
38 lines (24 loc) · 844 Bytes
/
webscraper.py
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
27
28
29
30
31
32
33
34
35
36
from bs4 import BeautifulSoup
from requests import get
from itertools import zip_longest
typ = input("ADJ or N").upper()
wrd = input("please enter a word: ")
if typ == "N":
website = f"https://www.verbformen.com/declension/nouns/?w={wrd}"
elif typ == "T":
website = f"https://www.verbformen.com/declension/adjectives/{wrd}.htm"
result = get(website)
src = result.content
soup = BeautifulSoup(src,"lxml")
# print(soup)
noun = soup.find("b").text
article = soup.find("p",{"class":"vGrnd rCntr"}).text
print(noun)
print(article[2:].replace("\n",""))
meaning = soup.find("p",{"class":"r1Zeile rU3px rO0px"})
word = meaning.text[3:-1]
print(word)
plural = soup.find("p",{"class":"vStm rCntr"}).text[1:]
print(plural.replace("\n·",""))
tye = soup.find("p",{"class","rInf"})
print(tye.find(attrs={"title":["noun","adjective"]}).text)