package main
import (
"fmt"
"database/sql"
_ "github.com/lib/pq"
"log"
"github.com/PuerkitoBio/goquery"
)
type SaitsInfo struct {
s_url,s_name,s_block string
}
func (this SaitsInfo) view(){
doc, err := goquery.NewDocument(this.s_url)
if err != nil {
log.Fatal(err)
}
doc.Find(".offers_box_table tr .txt_box2").Each(func(i int, s *goquery.Selection){
band := s.Find("a").Text()
title := s.Find("span").Text()
fmt.Printf("Review %d: %s - %s\n", i, band, title)
})
}
var (
url string
name string
block string
)
func main() {
db, err := sql.Open("postgres", "данные подключения")
if err != nil {
log.Fatal(err)
}
saits, err := db.Query(`SELECT url,name,block FROM saits`)
if err != nil {
log.Fatal(err)
}
for saits.Next(){
if err := saits.Scan(&url,&name,&block); err != nil{
log.Fatal(err)
}
si := SaitsInfo{url, name, block}
si.view()
}
defer db.Close()
}