I have a program that runs in IDLE on my laptop and also on my Android phone using a python app. When I try to run it on the Raspberry PI I get an error saying that "No module named request". If I remove request from the end of the statement it loads that portion. Then I get to another error at like 9 which says:
Traceback (most recent call last):
File "tibia.py", line 9, in <module>
words=input('Enter the character name you wish to monitor...\n')
File "<string>", line 1, in <module>
NameError: name 'NAME' is not defined
My code is below:
import urllib.request
import time
import smtplib
#define and format character name
words=input('Enter the character name you wish to monitor...\n')
words=str.replace(words," ","+")
words=words.title()
#prepare email body
content=('This is an automated email notifying you that '+words+' is online.')
#x for infinite loop
x=1
#adding anchors to character name
textToSearchFor = '=' + words + '"'
while x==1:
try:
site = urllib.request.urlopen('https://secure.tibia.com/community/?subtopic=worlds&world=Amera')
HTML = site.read().decode("utf-8")
if textToSearchFor in HTML:
print(words + ' is online.')
time.sleep(60)
#send email
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login('email','password')
mail.sendmail('email@gmail.com','email@gmail.com',content)
mail.close()
else:
print(words + ' is not online.')
time.sleep(60)
except:
print('Error fetching character status.')
time.sleep(60)