Golang访问抖音

栏目: Go · 发布时间: 5年前

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访问抖音》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volume 4,  Fascicle 3

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》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试