Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a contributors file #101

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Contributors log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Please sign your name below:

Dondeveto
64 changes: 42 additions & 22 deletions apis.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
import requests
import json
import sys

def fetch_weather(city):
try:
u = "https://query.yahooapis.com/v1/public/yql?q=select%20item.condition%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22{0}%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
r = requests.get(u.format(city))
r = requests.get(u.format("North Pole"))
j = json.loads(r.text)
results = j['query']['results']['channel']['item']
return results
except Exception as e:
print(e)
sys.stderr.write("Couldn't load current conditions\n")
return "Unkonw" # typo?


def fetch_stocks(ticker):
return "1 gazillon dollars" # TODO?

# TODO: More integrations
import re
import urllib.request
import time
import pyttsx

location = ""

def fetch_weather(location):
location=location.capitalize()
if location == "":
exit
else:
try:
city = location.replace(" ", "-")
url = "http://www.weather-forecast.com/locations/" + city + "/forecasts/latest"

data = urllib.request.urlopen(url).read()
data1 = data.decode("utf-8")
m = re.search('span class="phrase">', data1)
start = m.end()
end = start + 300
newString = data1[start:end]



m = re.search("</span>", newString)
end = m.start() - 2
final = newString[0:end]

engine = pyttsx.init()
engine.say(final)
engine.runAndWait()
return final
fetch_weather()
except:
return "The city doesn't exist"
#time.sleep(2)
fetch_weather()