2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vbsの作法 その75

Posted at

概要

vbsの作法、調べてみた。
練習問題、やってみた。

練習問題

vbsで、QiitaAPIを叩け。

サンプルコード


Function GetJson(url)
	SamAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
	hts = ""
	Set objHTTP = CreateObject("Microsoft.XMLHTTP")
	objHTTP.Open "GET", url, False
	objHTTP.SetRequestHeader "User-Agent", SamAgent
	objHTTP.Send
	Set objStream = CreateObject("ADODB.Stream")
	objStream.Type = 1
	objStream.Open
	objStream.Write objHTTP.responseBody
	objStream.Position = 0
	objStream.Type = 2
	objStream.Charset = "UTF-8"
	http_source = objStream.ReadText
	objStream.Close
	hts = http_source
	Set sc = CreateObject("MSScriptControl.ScriptControl")
	sc.Language = "JavaScript"
	sc.AddCode "var csv = '';"
	sc.AddCode "var res = " & hts & ";"
	s = "for (var i = 0; i < res.length; i++){csv += res[i].created_at + ' ';res[i].title = res[i].title.replace(/ /g, '-');"
	v = "csv += res[i].title + ' ';csv += res[i].url + ' ';csv += res[i].id + ' ';csv += res[i].user.id + '\n';}"
	sc.AddCode s & v
	Set cf = sc.CodeObject 
	WScript.Echo cf.csv
	Set objHTTP = Nothing
	Set objStream = Nothing
End Function

GetJson("https://qiita.com/api/v2/users/ohisama@github/items")



実行結果




2024-03-06T07:11:23+09:00 mindの研究-その74 https://qiita.com/ohisama@github/items/abe4e5fb1a0d93486fe5 abe4e5fb1a0d93486fe5 ohisama@github
2024-03-05T21:07:12+09:00 mindの研究-その73 https://qiita.com/ohisama@github/items/4a7e3c6acf18ebcc2550 4a7e3c6acf18ebcc2550 ohisama@github
2024-03-05T11:17:05+09:00 cscの作法-その468 https://qiita.com/ohisama@github/items/28f2b027066e7c9db03b 28f2b027066e7c9db03b ohisama@github
2024-03-05T09:00:05+09:00 cscの作法-その467 https://qiita.com/ohisama@github/items/0fa6f0941473f1c913a4 0fa6f0941473f1c913a4 ohisama@github
2024-03-05T08:28:05+09:00 cscの作法-その466 https://qiita.com/ohisama@github/items/e03f63960d3ecd3208df e03f63960d3ecd3208df ohisama@github
2024-03-05T08:19:21+09:00 cscの作法-その465 https://qiita.com/ohisama@github/items/d91075711cc96b347b8a d91075711cc96b347b8a ohisama@github
2024-03-05T08:14:09+09:00 cscの作法-その464 https://qiita.com/ohisama@github/items/30ef94de4acf502313eb 30ef94de4acf502313eb ohisama@github
2024-03-05T08:07:17+09:00 cscの作法-その463 https://qiita.com/ohisama@github/items/a397ccc7ef6fa388ae4a a397ccc7ef6fa388ae4a ohisama@github
2024-03-04T16:54:57+09:00 wslでelixir-その141 https://qiita.com/ohisama@github/items/902a1dde7457c9392fbd 902a1dde7457c9392fbd ohisama@github
2024-03-02T07:17:35+09:00 cscの作法-その462 https://qiita.com/ohisama@github/items/57cadf0b1629efb6cc98 57cadf0b1629efb6cc98 ohisama@github
2024-03-02T06:24:49+09:00 cscの作法-その461 https://qiita.com/ohisama@github/items/2d0a56ece7769cd89b06 2d0a56ece7769cd89b06 ohisama@github
2024-03-02T06:06:47+09:00 cscの作法-その460 https://qiita.com/ohisama@github/items/77b2253ae2e5e2fa6836 77b2253ae2e5e2fa6836 ohisama@github
2024-02-28T07:52:05+09:00 cscの作法-その459 https://qiita.com/ohisama@github/items/41e84ad2b7a36c217c5a 41e84ad2b7a36c217c5a ohisama@github
2024-02-26T04:32:35+09:00 PlunkerでPhaser.Physics-その15 https://qiita.com/ohisama@github/items/00e558a40781fbf684aa 00e558a40781fbf684aa ohisama@github
2024-02-26T04:13:43+09:00 PlunkerでPhaser.Physics-その14 https://qiita.com/ohisama@github/items/35ffd56de70c195b109d 35ffd56de70c195b109d ohisama@github
2024-02-25T10:45:34+09:00 PlunkerでPhaser.Physics-その13 https://qiita.com/ohisama@github/items/03ba871b4cfcb3ef2a6f 03ba871b4cfcb3ef2a6f ohisama@github
2024-02-25T10:40:35+09:00 PlunkerでPhaser.Physics-その12 https://qiita.com/ohisama@github/items/24f20cc0ae0957ecdab1 24f20cc0ae0957ecdab1 ohisama@github
2024-02-25T10:35:45+09:00 PlunkerでPhaser.Physics-その11 https://qiita.com/ohisama@github/items/f05827bf7cbb7c3c911c f05827bf7cbb7c3c911c ohisama@github
2024-02-25T10:30:57+09:00 PlunkerでPhaser.Physics-その10 https://qiita.com/ohisama@github/items/426748032579118f4b4b 426748032579118f4b4b ohisama@github
2024-02-25T10:25:21+09:00 PlunkerでPhaser.Physics-その9 https://qiita.com/ohisama@github/items/900c0fd857d534910bd5 900c0fd857d534910bd5 ohisama@github


以上。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?