import praw import ephem import requests user_agent = ("topRedditPost pyMachine 0.1") submissionArray = [] weatherURL = 'http://www.yr.no/place/Norway/Oslo/Oslo/Ljabru/hour_by_hour.html' weatherURL1 = 'http://www.yr.no/place/Norway/Sør-Trøndelag/Trondheim/Utleirvegen/hour_by_hour.html' stringId = '') - 2] forcastList = forcastDescription.split(', ') # Get the worded weather state weatherState = forcastList[0] while True: try: weatherState.index(':') weatherState = weatherState[weatherState.index(':') + 2:] pass except ValueError: forcastList[0] = weatherState + '.png' break # Get the temp value tempValue = forcastList[1] forcastList[1] = tempValue[12:] # Clean up any errors in the downpour try: forcastList[2] = forcastList[2].replace("\\xe2\\x80\\x93", "-") except ValueError: pass # Get the wind value and append the direction of the wind windValue = windDir = forcastList[4] windValue = windValue[:windValue.index('from') - 1] windDir = windDir[windDir.index('from') + len('from') + 1:] forcastList[4] = windValue forcastList.append(windDir) # Get the time of day forcastList.insert(0,timeOfDay()) print(forcastList) with open('weatherData.txt', 'w') as outputFile: for element in forcastList: outputFile.write(str(element) + '\n') def main(): getShowerThought() getWeatherReport() main()