func main() { for i := 1; i <= 3541; i++ { if e := model.DelTopic(int64(i), 1, -1000); e != nil { fmt.Println("删除 Topic id:" + strconv.Itoa(i) + "出现错误 " + fmt.Sprintf("%s", e) + "!") } } }
func (self *DeleteTopicHandler) Get() { flash := beego.NewFlash() tid, _ := self.GetInt(":tid") uid, _ := self.GetSession("userid").(int64) role, _ := self.GetSession("userrole").(int64) if tid > 0 { if e := model.DelTopic(tid, uid, role); e != nil { self.TplNames = "error.html" flash.Error("删除 Topic id:" + strconv.Itoa(int(tid)) + "出现错误 " + fmt.Sprintf("%s", e) + "!") flash.Store(&self.Controller) return } } self.Redirect("/?ver="+strconv.Itoa(int(time.Now().UnixNano())), 302) }
//删除帖子 func (self *TopicHandler) Delete() { if hash := self.GetString("hash"); hash != "" { if rsa_decrypt_content, err := helper.ReceivingPackets(true, hash, "DELETE", self.Ctx.Input.RequestBody, aesPublicKey, rsaPublicKey, rsaPrivateKey); err == nil { tid, _ := self.GetInt(":objectId") var tp *model.Topic json.Unmarshal(rsa_decrypt_content, &tp) if tid == tp.Id && tid > 0 { if e := model.DelTopic(tid, 1, -100000); e != nil { self.Data["json"] = "Delete failed!" } else { self.Data["json"] = "Delete success!" } //self.ServeJson() self.Ctx.WriteString(self.Data["json"].(string)) } else { fmt.Println("401 Unauthorized!") self.Abort("401") } } else { fmt.Println("401 Unauthorized!") self.Abort("401") } } else { fmt.Println("401 Unauthorized!") self.Abort("401") } }
func main() { urls := []string{} //循环所有页面查找所有图片的网页链接 for i := 1; i <= 50; i++ { x, _ := goquery.NewDocument("http://www.mzitu.com/page/" + strconv.Itoa(i)) x.Find(".imageLink").Each(func(idx int, s *goquery.Selection) { v, b := s.Attr("href") if b == true { urls = append(urls, v) } }) } //遍历所有图片网址 提取图片URL后保存到数据库 for k, v := range urls { fmt.Println("<url #[", k, "]# url>") SelfPage(v) //单独处理网页 } //读取图片集合并下载 if imgs, e := GetSpiderData(0, 0, "id"); e == nil { j := int64(0) for k, v := range *imgs { fmt.Println("#>", k, ":", v.Url) if fpath, err := Download(v.Url); err == nil { fmt.Println("fpath:", fpath) fmt.Println(helper.Local2url(fpath)) if helper.Exist(fpath) { if thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, e := helper.MakeThumbnails(helper.Local2url(fpath)); thumbnails != "" && thumbnailslarge != "" && thumbnailsmedium != "" && thumbnailssmall != "" && e == nil { j += 1 title := "性感系 " + v.Title + " 美女季/第" + fmt.Sprint(time.Now().Format("0102-150405")) + "期" cid := int64(1) nid := int64(4) //2 uid := int64(1) role := int64(-1000) if 1899 < j <= 3541 { model.DelTopic(j, uid, role) id, err := UpdateTopic(j, title, "<p><img src=\""+helper.Local2url(fpath)+"\" alt=\""+v.Title+"\"/></p>", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, cid, nid, uid) if err != nil { fmt.Println("###################发布话题", id, "出错####################", err) } } else { id, err := AddTopic(title, "<p><img src=\""+helper.Local2url(fpath)+"\" alt=\""+v.Title+"\"/></p>", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, cid, nid, uid) if err != nil { fmt.Println("###################发布话题", id, "出错####################", err) } } } else { fmt.Println("@@@@@@@@@@@@@@@处理缩略图出错@@@@@@@@@@@@@@@@", err) os.Remove(fpath) os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_large.jpg"))) os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_medium.jpg"))) os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_small.jpg"))) } } } } } }