好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 llacjj 于 2023-7-13 20:34 编辑
此源码仅供参考,1楼有多个域名,指向同一主机
[Golang] 纯文本查看 复制代码 package main //go build -ldflags "-s -w"[/size][size=5]import(`io`;`os`;`fmt`;`regexp`;`strings`;`net/http`;`crypto/tls`)
var(X=[...]string{`|`,`\`,`/`,`<`,`>`,`:`,`*`,`?`,`"`}
book=map[string]string{
`Referer`:`https://www.qiuyegexs.com/`,
`Content-Type`:`application/x-www-form-urlencoded`,
`Cookie`:`5yd0z_t=14; 5yd0z_cdn=%2F%2Fq.qiuyegexs.com%2Fstatic%2F; 5yd0zlatest=6mmv; 5yd0zauth=%012168791599300edIjQ2NTYyOVx0NmE0ODJjZGZcdGNjZGRielx0MTMwMzA1MDYyMTBcdDM1NTg4MzU1OTVAcXEuY29tXHQxNjkwNTA3OTkzXHQi`,
`User-Agent`:`Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0`}
S=`https://www.qiuyegexs.com`
R1=regexp.MustCompile(`<span class="s2"><a href="(/\w+\.html)">(.*?)</a></span>`)
R2=regexp.MustCompile(`/downtxt/\w+\.txt`)
R3=regexp.MustCompile(`<h1>(.*?)</h1>`))
func main() {
var key string
fmt.Printf(`输入关键字:`)
fmt.Scanln(&key)
c:=&http.Client{Transport: &http.Transport{TLSClientConfig:&tls.Config{InsecureSkipVerify: true}}}
r,_:=http.NewRequest(`POST`,S+`/search/`,strings.NewReader(`keyword=`+key))
for k,v:=range book{r.Header.Set(k,v)}
p,_:=c.Do(r)
defer p.Body.Close()
b,_:=io.ReadAll(p.Body)
r1:=R1.FindAllStringSubmatch(string(b),-1)
for i:=0;i<len(r1);i++{fmt.Println(i+1,r1[i][2])}
fmt.Printf("\n默认全部下载,1-%d选择下载:",len(r1))
n:=0
fmt.Scanln(&n)
if n>0{Search(r1[n-1][1])}else{
for i:=0;i<len(r1);i++{Search(r1[i][1])}}}
func Search(uri string){
c:=&http.Client{Transport: &http.Transport{TLSClientConfig:&tls.Config{InsecureSkipVerify: true}}}
r,_:=http.NewRequest(`GET`,S+uri,nil)
for k,v:=range book{r.Header.Set(k,v)}
p,_:=c.Do(r)
b,_:=io.ReadAll(p.Body)
defer p.Body.Close()
r1:=string(R2.Find(b))
r2:=R3.FindSubmatch(b)
Down(S+r1,string(r2[1])+`.txt`)}
func Down(uri,name string){
for i:=0;i<len(X);i++{name=strings.ReplaceAll(name,X[i],``)}
c:=&http.Client{Transport: &http.Transport{TLSClientConfig:&tls.Config{InsecureSkipVerify: true}}}
r,_:=http.NewRequest(`GET`,uri,nil)
for k,v:=range book{r.Header.Set(k,v)}
p,_:=c.Do(r)
defer p.Body.Close()
f,_:=os.Create(name)
defer f.Close()
io.Copy(f,p.Body)
fmt.Println(name,`已下载`)} |
免费评分
-
查看全部评分
|