package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
func main() {
var newurl string
input := bufio.NewScanner(os.Stdin)
fmt.Println("输入一个网址")
input.Scan()
fmt.Println("你输入的是:", input.Text())
var oldurl string = input.Text()
client := &http.Client{}
reqest, _ := http.NewRequest("GET", oldurl, nil)
reqest.Header.Set("User-Agent", "request")
response, _ := client.Do(reqest)
if response.StatusCode == 200 {
body, _ := ioutil.ReadAll(response.Body)
bodystr := string(body)
newurl = Between(bodystr, "https://aweme.snssdk.com", "&line")
newurl = "https://aweme.snssdk.com" + (strings.Replace(newurl, "playwm", "play", -1))
fmt.Println("解析的网站:" + newurl)
resp, err := http.Head(newurl)
if err != nil {
fmt.Println("err:", err)
}
defer resp.Body.Close()
fmt.Println(resp.Request.URL)
}
}
//取中间字符串
func Between(str, starting, ending string) string {
s := strings.Index(str, starting)
if s < 0 {
return ""
}
s += len(starting)
e := strings.Index(str[s:], ending)
if e < 0 {
return ""
}
return str[s : s+e]
}
以上所述就是小编给大家介绍的《Golang访问抖音》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 像访问本地文件系统一样访问云存储
- 如何访问P站 | Pixiv 被墙无法访问的解决方法
- Spark实战--寻找5亿次访问中,访问次数最多的人
- 逆天操作-将https访问通过反向代理转换成http访问
- node.js – 数字海洋上的访问节点应用程序 – 无法访问此站点
- GitHub 访问加速指南
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Art of Computer Programming, Volume 4, Fascicle 3
Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99
Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!