Last active
October 26, 2015 02:07
-
-
Save high5/c6f66760171157e8fe92 to your computer and use it in GitHub Desktop.
Go(goquery)でQiitaのスクレイピングライブラリをつくった ref: http://qiita.com/high5/items/8c8dc426fb731d668007
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("------------------------------------------------------------------------------") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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