- 博客(15)
- 收藏
- 关注
原创 关于在go并发五 中 存在的问题
在 函数 TestStopTimeUpdate() 中,有这样一句代码,是存放在每一个分类下面的 书籍,然后 key 为书籍的分类名,具体的 元素 []int 为 预设的分页码,这样就达到 每一类 下面 每次都能抓取 新的书籍内容。mapPage := make(map[string][]int)但是 在代码中 有 对这个分页map 有读和写 操作mapPage[tuName] = sliceInt......mapPage[tuName] = mapPage[tuName][1:len(m
2020-08-24 06:20:03
220
原创 go并发4 pools 协程池代码
pools包下pool.gopackage poolsimport ( "tools/reptilesoper/reptilesengine/gogo/timerupdate")type GoPools struct { PoolName string //协程池名称 GoWorkNum int //协程工作的数量 通过调度层哪边根据任务情况 来安排协
2020-08-22 07:08:06
228
原创 go并发5 test 测试
test 包下面zonghengtimeupdateTest.go免责声明 在使用本程序时,本人以供读者学习使用,并没有攻击其他网站意图,请读者设置对应源码参数时酌情考虑,切记,切记package test//import ( "dao" "fmt" "mode" "strconv" "strings" "time" "tools/otheroper" "tools/reptilesoper/reptilesengine/gogo/dispatch" "tools/repti
2020-08-22 07:07:33
683
原创 golang 常用工具包
convertoperpackage convertoperimport ( "encoding/binary" "reflect" "unsafe")//byte数组转 int32func BytesToInt32(buf []byte) int32 { return int32(binary.BigEndian.Uint32(buf))}//byte数组转 int64func BytesToInt64(buf []byte) int64 { return int64(bi
2020-08-22 07:07:12
645
原创 go并发3 timerupdate 包 定时更新器包
timerUpdate包 有三个文件tuclayer.go 定时更新器层tu.go 定时更新器task.go 任务tuclayer.go 定时更新器层package timerupdateimport ( "time")//Timing updater component layer//定时更新器组件层接口type TUCLayer struct { //定时器集合 TUs []*TimerUpdate}//创建定时器func CreateExcuTu(timerN
2020-08-21 07:59:49
324
原创 go并发2 dispatch 调度层包
//dispatch 调度层包分为三个文件centerdispatchlayer.go //调度层centerdispatch.go //调度器globals.go //全局类1:centerdispatchlayer.gopackage dispatchimport ( "fmt" "tools/reptilesoper/reptilesengine/gogo/pools" "tools/reptilesoper/reptilesengine/gogo/timerupdate"
2020-08-21 07:53:58
521
原创 golang 并发( 配合爬虫写的 并发小框架)
之前前面提到 爬虫 ,只是单纯的单条执行,既然用go来写爬虫,那么必须要用到 并发来做这件事情废话不多说,先上 设计图
2020-08-21 06:59:40
355
原创 go 爬虫4调用示例
test.go//初始化func GetZX() hand.IParseProcess { var zh hand.IParseProcess = &hand.ZongHengXS{PP: struct { ClassifRequestUrl string ClassifRegexpstr string BookRequestUrl string BookRegexpstr string ChapterRequestUrl
2020-08-21 06:44:46
95
原创 go爬虫3
hand 包下zonghengxs.go免责声明: 本文章仅供于学习使用,不能拿入其他用途,后果自负哈,package handimport ( "regexp" "strconv" "strings" "tools/otheroper")//type ZongHengXS struct { PP ParseProcess}func (zh *ZongHengXS) GetClassifs() HandResult { content := zh.PP.GetConte
2020-08-21 06:36:13
142
原创 go爬虫 2
hand 包下handresult.gopackage handtype IParseProcess interface { //查询书籍分类 GetClassifs() HandResult //获取某个分类下面的小说 GetBooks(classifyUrl string,pageIndex int) (HandResult,bool) //获取某个小说下面的章节 GetChapters(ChapterRequestUrl string) HandResult //获取某个小说的一
2020-08-21 06:32:29
124
原创 go 爬虫代码编写 (单例)
package handimport ( "fmt" "io/ioutil" "net/http" "strings" "tools/otheroper")//请求地址 返回内容数组流func ReptilesDo(url string) ([]byte, error) { httprequest, err := http.NewRequest(http.MethodGet, url, nil) //httprequest.Close = true //防止Go传输本身添加
2020-08-21 06:27:44
275
原创 golang dbhelper 3 调用示例
调用示例我把在调用之间 加入 dao 文件目录中,因此main 函数调用之前 还有建立一个包daopackage daoimport ( "fmt" "mode" "tools/dboper")func InsertBooks(books mode.Books) { if dboper.AddStruct(books){ fmt.Println("add success") }else{ fmt.Println("add error") }}func Batch
2020-08-21 06:17:41
215
原创 dbhelper 2 补充说明
关于小工具代码的补充调用示例 还是 放在第三篇吧下面是 reflectoper.GetStructMsg()package reflectoperimport ( "errors" "reflect" "strconv" "strings")type ModeObj struct { Field string //多个字段字符串,以,分隔 StructName string //结构名称、 ValueStrs string //多个值的字符串,以,分隔}//获
2020-08-21 05:58:27
120
原创 golang dbhelper
package dboperimport (“database/sql”“fmt”_ “github.com/go-sql-driver/mysql”“reflect”“strings”“tools/convertoper”“tools/otheroper”“tools/reflectoper”)var db *sql.DB//该dbhelper 没有加入sql注入【验证】//初始化数据库连接 建议放在main init()中func InitDB() (err error) {
2020-08-21 05:38:51
341
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人