dimanche 20 novembre 2016

How can i use class inside of if?

When i run it i get an NameError. It says soup is undefined what should i do to fix it?

Note: After Try i have expect too but i didnt add it that part is correct :)

while True:
    try:
        import requests
        from bs4 import BeautifulSoup
        print("Not: Unutmayın Bir Karakter Max. 100 Değerinde Olabilir!")
        a = int(input("Hızınızı Girin: "))
        b = int(input("Gücünüzü Girin: "))
        c = int(input("Zekanızı Girin: "))

        class URL:
            def geturl(self):
                url = "http://ift.tt/2gtmmKQ"
                r = requests.get(url)
                soup = BeautifulSoup(r.content, "html.parser")
                print(soup)

        for insan in soup.find_all("p"):
            icerik = insan.text
            print(icerik)
        if 0 <= a <= 10 and 0 <= b <= 10 and 0 <= c <= 10:
            print("Insan Sınıfı")
            cevap = input("Karakteriniz ile ilgili bilgi almak ister misiniz[E,H]")
            if cevap == "Evet" or cevap == "evet" or cevap == "e" or cevap =="E":
                print(soup)

Aucun commentaire:

Enregistrer un commentaire