def _readHTML(stockSymbol):
    WEBSITE = 'https://finance.yahoo.com/quote/'
    page = InStream(WEBSITE + stockSymbol)
    html = page.readAll()
    return html
예제 #2
0
    W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W,
    W, W, W, W, W, W, W, W, W, W, W, W, W, W
]

useSensor = True

while True:
    events = sense.stick.get_events()
    for event in events:
        if event.action == 'pressed' and event.direction != 'middle':
            if useSensor:
                print('Using data from openweathermap.org')
                stream = InStream(
                    'http://api.openweathermap.org/data/2.5/weather?q=Jena&units=metric&lang=de&APPID=7fa8d8270c50a5274bc055415e448b35'
                )
                weather = json.loads(stream.readAll())['main']
            else:
                print('Using data from Raspberry Pi sensors')
            useSensor = not useSensor
    if useSensor:
        if sense.humidity > 80 and sense.temp > 20:
            sense.set_pixels(rainbow)
        elif sense.humidity <= 80 and sense.temp > 20:
            sense.set_pixels(sunny)
        elif sense.humidity > 80 and sense.temp < 0:
            sense.set_pixels(snow)
        else:
            sense.clear()
    else:
        if weather['humidity'] > 80 and weather['temp'] > 20:
            sense.set_pixels(rainbow)
예제 #3
0
def _readHTML(stockSymbol):
    WEBSITE = 'http://finance.yahoo.com/q?s='
    page = InStream(WEBSITE + stockSymbol)
    html = page.readAll()
    return html
예제 #4
0
파일: cat.py 프로젝트: davidhuizhou/python
# cat.py
# -----------------------------------------------------------------------

import sys
from instream import InStream
from outstream import OutStream

# Copy files or web pages whose names are given by sys.argv[1:n-2]
# to the file whose name is given by sys.argv[n-1].

inFilenames = sys.argv[1 : len(sys.argv) - 1]
outFilename = sys.argv[len(sys.argv) - 1]
outstream = OutStream(outFilename)
for filename in inFilenames:
    instream = InStream(filename)
    s = instream.readAll()
    outstream.write(s)

# -----------------------------------------------------------------------

# more in1.txt
# This is

# more in2.txt
# a tiny
# test.

# python cat.py in1.txt in2.txt out.txt

# more out.txt
# This is
예제 #5
0
# cat.py
#-----------------------------------------------------------------------

import sys
from instream import InStream
from outstream import OutStream

# Copy files or web pages whose names are given by sys.argv[1:n-2]
# to the file whose name is given by sys.argv[n-1].

inFilenames = sys.argv[1:len(sys.argv) - 1]
outFilename = sys.argv[len(sys.argv) - 1]
outstream = OutStream(outFilename)
for filename in inFilenames:
    instream = InStream(filename)
    s = instream.readAll()
    outstream.write(s)

#-----------------------------------------------------------------------

# more in1.txt
# This is

# more in2.txt
# a tiny
# test.

# python cat.py in1.txt in2.txt out.txt

# more out.txt
# This is
예제 #6
0
def _readHTML(city):
    WEBSITE = 'https://15tianqi.cn/'
    page = InStream(WEBSITE + city + '15tian')
    html = page.readAll()
    return html