go 伪造User-Agent 抓取网页代码

go 伪造User-Agent 抓取网页代码

package main import ( "fmt" "io/ioutil" "net/http" "time" ) func main() { client := &http.Client{ Timeout: 2 * time.Second, } req, _ := http.NewRequest("GET", "http://www.xxxx.vip", nil) req...

Goland 2020-10-26 PM 2389℃ 0条
go 获取自身路径

go 获取自身路径

package main import ( "fmt" "syscall" "unicode/utf16" "unsafe" ) var( kernel=syscall.MustLoadDLL("kernel32.dll") getModuleFileNameProc = kernel.MustFindProc("GetModuleFileNameW") ) func getExePath() (exePath s...

Goland 2020-10-26 PM 2076℃ 0条
goland 提交表单

goland 提交表单

package main import ( "net/http" "net/url" "fmt" "io/ioutil" ) func main() { //?mod=forumdisplay&fid=42 params:=url.Values{ "action":{"add"}, "name":{"42"}, "tel":{"13...

Goland 2020-10-26 PM 2367℃ 0条
go字符串的遍历输出

go字符串的遍历输出

package main import ( "fmt" ) func main() { str := "Hello,世界" //方法一:格式化打印 for _, ch1 := range str { fmt.Printf("%q",ch1) //单引号围绕的字符字面值,由go语法安全的转义 } fmt.Println("==========>方法二") //方法二:转化输出格式 for _, ch2 := range s...

Goland 2020-10-26 PM 2718℃ 0条
go 正则贪婪匹配

go 正则贪婪匹配

package main import ( "fmt" "regexp" ) func main(){ r,_:=regexp.Compile("aaa(.*?)bbb") matches:=r.FindAllString("42342342aaa111111111111bbbasdfafasdfas",-1) // %q quote element to see... instead of %s fmt.Printf("%q \n"...

Goland 2020-10-26 PM 2436℃ 0条
go UTF-8 to gbk 编码转换

go UTF-8 to gbk 编码转换

examplepackage main import "fmt" import "github.com/axgle/mahonia" func main(){ enc:=mahonia.NewEncoder("gbk") //converts a string from UTF-8 to gbk encoding. fmt.Println(enc.ConvertString("hello,世界")) }

Goland 2020-10-26 PM 3785℃ 0条
golang中文字符编码转换

golang中文字符编码转换

golang处理中文时默认是utf8,当遇到其他如GBK字符是就会出现乱码,此处介绍golang 官方golang.org/x/text/encoding/simplifiedchinese包下的编码转换package main import "golang.org/x/text/encoding/simplifiedchinese" type Charset string const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") ) fu...

Goland 2020-10-26 PM 2140℃ 0条
go 语言模拟百度登录

go 语言模拟百度登录

go 语言模拟百度登录1.参考网上Python的例子自己写了一个go语言的。这个仅供学习技术参考,为了方便有部分参数直接phantomjs执行js获取,代码基本都有注释,测试打印没有删除,还请见谅!2.本文参考http://blog.csdn.net/qiye_/article/details/52884491话不多说,直接上码package main import ( "errors" "fmt" "math/big" "crypto/rsa" "byt...

Goland 2020-10-26 PM 2545℃ 0条
goland 获取unix时间

goland 获取unix时间

//获取unix时间 func getMillisecond() int64{ MS := time.Now().Unix() return MS }

Goland 2020-10-26 PM 2384℃ 0条
mysql 按日期统计

mysql 按日期统计

mysql 按日期统计按年汇总,统计:select sum(mymoney) as totalmoney, count(*) as sheets from mytable group by date_format(col, '%Y');按月汇总,统计: select sum(mymoney) as totalmoney, count(*) as sheets from mytable group by date_format(col, '%Y-%m');按季度汇总,统计: select sum(mymoney) as totalmoney,count(*) as sheets from ...

数据库 2020-10-26 PM 2269℃ 0条
sendcloud golang 发送短信 示例代码

sendcloud golang 发送短信 示例代码

package main import ( "fmt" "crypto/md5" "encoding/hex" "sort" "strings" "net/url" "bytes" "net/http" "io/ioutil" ) var urls = "http://www.sendcloud.net/smsapi/s...

Goland 2020-10-26 PM 2635℃ 0条