-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_it_quote.txt
57 lines (52 loc) · 2.65 KB
/
get_it_quote.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import urllib
from xml.dom import minidom
WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'
def weather_for_zip(zip_code):
url = WEATHER_URL % zip_code
dom = minidom.parse(urllib.urlopen(url))
>>> ro = x.getroot()
>>> ro
<Element root at d37788>
>>> dir(ro)
['__delitem__', '__delslice__', '__doc__', '__getitem__', '__getslice__', '__init__',
'__len__', '__module__', '__repr__', '__setitem__', '__setslice__', '_children', 'ap
pend', 'attrib', 'clear', 'find', 'findall', 'findtext', 'get', 'getchildren', 'getit
erator', 'insert', 'items', 'keys', 'makeelement', 'remove', 'set', 'tag', 'tail', 't
ext']
>>> ro.text
u'Mon Mar 14 10:07:15 MSK 2011\nInternet Trading ExtraHours;\nISSUE;BID;ASK;VOLUME;\n
CLOSED\n\u041d\u043e\u0440.\u041d\u0438\u043a\u0435\u043b\u044c \u0430\u043e;0.0000;0
.0000;0;\n\u0421\u0435\u0432\u0421\u0442-\u0430\u043e;0.0000;0.0000;0;\nHOBAT\u042dK
\u0430\u043e;0.0000;0.0000;0;\n\u0421\u0443\u0440\u0433\u043d\u0444\u0433\u0437-\u043
f;0.0000;0.0000;0;\n\u0423\u0440\u0430\u043b\u0421\u0432\u0418-\u0430\u043e;0.0000;0.
0000;0;\n\u0412\u0422\u0411;0.0000;0.0000;1,750,000;\n\u0421\u0431\u0435\u0440\u0431\
u0430\u043d\u043a-\u043f;0.0000;0.0000;0;\n\u0421\u0431\u0435\u0440\u0431\u0430\u043d
\u043a \u0430\u043e;0.0000;0.0000;0;\n\u0413\u0430\u0437\u043f\u0440\u043e\u043c\u043
d\u0435\u0444\u0442\u044c-\u0430\u043e;0.0000;0.0000;0;\n\u0413\u0438\u0434\u0440\u04
3e\u041e\u0413\u041a;0.0000;0.0000;0;\n\u0413\u0430\u0437\u043f\u0440\u043e\u043c \u0
430\u043e;0.0000;0.0000;420;\n\u041b\u0423\u041a\u041e\u0419\u041b \u0430\u043e;0.000
0;0.0000;0;\n\u0420\u043e\u0441\u043d\u0435\u0444\u0442\u044c \u0430\u043e;0.0000;0.0
000;0;\n\u0421\u0443\u0440\u0433\u0443\u0442\u043d\u0435\u0444\u0442\u0435\u0433\u043
0\u0437 \u0430\u043e;0.0000;0.0000;0;\n\u0420\u043e\u0441\u0442\u0435\u043b\u0435\u04
3a\u043e\u043c \u0430\u043e;0.0000;0.0000;0;\n\u041c\u0422\u0421 \u0430\u043e;0.0000;
0.0000;1,100;\n\u0422\u0430\u0442\u043d\u0435\u0444\u0442\u044c \u0430\u043e;0.0000;0
.0000;0;\n\u041f\u043e\u043b\u044e\u0441\u0417\u043e\u043b\u043e\u0442\u043e;0.0000;0
.0000;0;\n'
>>> to_file = ro.text
>>> data
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data' is not defined
>>> import codecs
>>> data = codecs.open('quotation_xml', encoding='utf-8', mode='w+')
>>> data.write(to_file)
>>> data.close()
>>> data = codecs.open('quotation_xml1', encoding='utf-8', mode='w+')
>>> data.write(to_file)
>>> data.close()
>>> help(history)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'history' is not defined
>>> getElementsByTagName