Skip to content

Instantly share code, notes, and snippets.

@high5
Last active October 26, 2015 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save high5/c6f66760171157e8fe92 to your computer and use it in GitHub Desktop.
Save high5/c6f66760171157e8fe92 to your computer and use it in GitHub Desktop.
Go(goquery)でQiitaのスクレイピングライブラリをつくった ref: http://qiita.com/high5/items/8c8dc426fb731d668007
package main
import (
"fmt"
"github.com/high5/go-qiita-explore"
"log"
)
func main() {
explore := explore.NewExplore()
articles, err := explore.GetStocks("Ruby")
if err != nil {
log.Fatal(err)
}
for index, article := range articles {
if index == 0 {
fmt.Println("------------------------------------------------------------------------------")
}
fmt.Printf("title: %s \n", article.Title)
fmt.Printf("url: %s \n", article.URL.String())
fmt.Printf("user: %s \n", article.UserName)
fmt.Printf("user_url: %s \n", article.UserURL.String())
fmt.Printf("stock: %d \n", article.StockCount)
fmt.Printf("created_time: %s \n", article.CreatedTime.Format("2006-01-02"))
for index, tag := range article.Tags {
tagNo := index + 1
fmt.Printf("tag%d: %s (http://qiita.com/tags/%s)\n", tagNo, tag, tag)
}
fmt.Println("------------------------------------------------------------------------------")
}
}
package main
import (
"fmt"
"github.com/high5/go-qiita-explore"
"log"
)
func main() {
explore := explore.NewExplore()
articles, err := explore.GetItems("JavaScript", 1)
if err != nil {
log.Fatal(err)
}
for index, article := range articles {
if index == 0 {
fmt.Println("------------------------------------------------------------------------------")
}
fmt.Printf("title: %s \n", article.Title)
fmt.Printf("url: %s \n", article.URL.String())
fmt.Printf("user: %s \n", article.UserName)
fmt.Printf("user_url: %s \n", article.UserURL.String())
fmt.Printf("stock: %d \n", article.StockCount)
fmt.Printf("created_time: %s \n", article.CreatedTime.Format("2006-01-02"))
for index, tag := range article.Tags {
tagNo := index + 1
fmt.Printf("tag%d: %s (http://qiita.com/tags/%s)\n", tagNo, tag, tag)
}
fmt.Println("------------------------------------------------------------------------------")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment