Get stock articles of infrastructure engineer yuta with Qiita API

This is a program created at the time of the Mokumokukai held at the online salon sponsored by infrastructure engineer yuta. I made it when I was studying to get information using API in Go.

Source code

main.go


package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

type Item struct {
	Title string `json:"title"`
	User  Users
}
type Users struct {
	Name string `json:"name"`
}

func main() {
	targetName := "yuta_vamdemic"
	getUrl := "http://qiita.com/api/v2/users/" + targetName + "/stocks?page=1&per_page=5"

	resp, err := http.Get(getUrl)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}

	var data []Item

	if err := json.Unmarshal(body, &data); err != nil {
		log.Fatal(err)
	}

	fmt.Printf("##[%s]Stock article##\n", targetName)

	for _, item := range data {
		fmt.Printf("%s %s\n", item.User.Name, item.Title)
	}
}

Execution result

##[yuta_vamdemic]Stock article##
Silently install SQL Server Management Studio with PowerShell
 [Terraform]CI for Terraform repository with CodeBuild
Kometan React Material for beginners-UI [How to use Dialog]
Square UseEffect (componentDidMount-like) that moves only once at the beginning
Understand seira React hooks from the basics(useState edition)

Point

I was worried because I didn't know how to write the structure around here.

python


type Item struct {
	Title string `json:"title"`
	User  Users
}
type Users struct {
	Name string `json:"name"`
}

Impressions

Getting stock articles is like a stalker, isn't it? I've been so busy lately that I haven't been able to attend the salon.

Recommended Posts

Get stock articles of infrastructure engineer yuta with Qiita API
Get the number of PVs of Qiita articles you posted with API
Get the number of articles accessed and likes with Qiita API + Python
[First API] Try to get Qiita articles with Python
Get a list of articles posted by users with Python 3 Qiita API v2
I tried to get the authentication code of Qiita API with Python.
Get stock price data with Quandl API [Python]
[Python] Get user information and article information with Qiita API
After hitting the Qiita API with Python to get a list of articles for beginners, we will visit the god articles
Get information with zabbix api
Get stock price with Python
Qiita API Oauth with Django
Get ranking with Rakuten API
Get US stock price from Python with Web API with Raspberry Pi
Get reviews with python googlemap api
Quine Post with Qiita API (Python)
Get Qiita trends with Python scraping
I tried to get the movie information of TMDb API with Python
Get the minutes of the Diet via API
Get holidays with the Google Calendar API
[Python] Get Python package information with PyPI API
Make API of switchbot thermo-hygrometer with Node-RED
Get coincheck virtual currency information with API ♪
Get lots of your tweets with Tweepy
[Python] Automatically totals the total number of articles posted by Qiita using the API
Get the stock price of a Japanese company with Python and make a graph