On Jan 19, 2011, at 2:19 PM, K4 Monk wrote:
> How does the http request in yahoo.q work?
>
> txt: `:http://ichart.finance.yahoo.com “GET /table.csv?s=” , (string
stock) , params , " http/1.0 host:ichart.finance.yahoo.com ";
>
> I couldn’t find any documentation for making http requests through q
elsewhere (or have I missed?)
not sure if it’s documented for q specifically, but it’s pretty standard
make a filehandle of the protocol and hostname, and “send” (apply) to
that an http 1.1 request
(not sure why the example has 1.0 in the version since host: is a
1.1-only header…)
anything you can do in telnet .. 80 will work here
pro% telnet ichart.finance.yahoo.com 80
Trying 76.13.116.133…
Connected to any-chart.finance-global.a01.yahoodns.net.
Escape character is ‘^]’.
GET /table.csv?s=AAPL http/1.1
host:ichart.finance.yahoo.com
HTTP/1.1 200 OK
Date: Thu, 20 Jan 2011 00:31:03 GMT
P3P: policyref=“http://info.yahoo.com/w3c/p3p.xml”, CP=“CAO DSP COR
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi
PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC
GOV”
Cache-Control: private
Connection: close
Transfer-Encoding: chunked
Content-Type: text/csv
fe67
Date,Open,High,Low,Close,Volume,Adj Close
2011-01-19,348.35,348.60,336.88,338.84,40494700,338.84
2011-01-18,329.52,344.76,326.00,340.65,66831600,340.65
2011-01-14,345.89,348.48,344.44,348.48,10998600,348.48
2011-01-13,345.16,346.64,343.85,345.68,10599300,345.68
2011-01-12,343.25,344.43,342.00,344.42,10790700,344.42
2011-01-11,344.88,344.96,339.47,341.64,15814500,341.64
2011-01-10,338.83,343.23,337.17,342.45,16000400,342.45
2011-01-07,333.99,336.35,331.90,336.12,11096800,336.12
2011-01-06,334.72,335.25,332.90,333.73,10709500,333.73
2011-01-05,329.55,334.34,329.50,334.00,9058700,334.00
2011-01-04,332.44,332.50,328.15,331.29,11038600,331.29
2011-01-03,325.64,330.26,324.84,329.57,15883600,329.57
2010-12-31,322.95,323.48,321.31,322.56,6911000,322.56
2010-12-30,325.48,325.51,323.05,323.66,5624800,323.66
..
pro% q
q):http://ichart.finance.yahoo.com "GET /table.csv?s=AAPL http/1.0 host:ichart.finance.yahoo.com " "HTTP/1.1 200 OK Date: Thu, 20 Jan 2011 00:33:51 GMT P3P: policyref="h.. q)-1
:http://ichart.finance.yahoo.com "GET /table.csv?s=AAPL
http/1.0 host:ichart.finance.yahoo.com ";
HTTP/1.1 200 OK
Date: Thu, 20 Jan 2011 00:32:56 GMT
P3P: policyref=“http://info.yahoo.com/w3c/p3p.xml”, CP=“CAO DSP COR
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi
PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC
GOV”
Cache-Control: private
Connection: close
Content-Type: text/csv
Date,Open,High,Low,Close,Volume,Adj Close
2011-01-19,348.35,348.60,336.88,338.84,40494700,338.84
2011-01-18,329.52,344.76,326.00,340.65,66831600,340.65
2011-01-14,345.89,348.48,344.44,348.48,10998600,348.48
2011-01-13,345.16,346.64,343.85,345.68,10599300,345.68
2011-01-12,343.25,344.43,342.00,344.42,10790700,344.42
2011-01-11,344.88,344.96,339.47,341.64,15814500,341.64
2011-01-10,338.83,343.23,337.17,342.45,16000400,342.45
2011-01-07,333.99,336.35,331.90,336.12,11096800,336.12
2011-01-06,334.72,335.25,332.90,333.73,10709500,333.73
2011-01-05,329.55,334.34,329.50,334.00,9058700,334.00
2011-01-04,332.44,332.50,328.15,331.29,11038600,331.29
2011-01-03,325.64,330.26,324.84,329.57,15883600,329.57
2010-12-31,322.95,323.48,321.31,322.56,6911000,322.56
2010-12-30,325.48,325.51,323.05,323.66,5624800,323.66
..