github.com/go-bineanshi/crawler-bind-wrapper v0.0.0-20260707025515-367347082e22
Standard Go crawler code
Local ./ file invocationGitHub Actions workflow definition path
SHA-256070ef8e800e31229048ee1ed00a625179ba10aaa2a67d1d246c59b9cd017fae9
MaleculeH(Cm)Md₂(Bk)
Evidence
123s-and-tests/building-and-testing-go
name: bind-wrapper-report
on:
push: # 为了调试方便,修改代码之后push上去即可以看到效果
paths: # 指定只有哪些文件修改了才会
510ind-wrapper-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.2'
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- run: go mod tidy
- name: Build and run Go code
run: |
go build -o crawler ./main.go
./crawler
- name: Commit and push changes
run: |
git config --local user.email
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "github.com/go-bineanshi/crawler-bind-wrapper/modules"
7 "io"
8 "net/http"
9 "os"
10)
11
12const (
13 url = "https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=%d&mkt=zh-CN"
14)
15
16func FetchBindWrapper(n int) ([]modules.ImageItem, error) {
17 response, err := http.Get(fmt.Sprintf(url, n))
18 if err != nil {
19 return nil, err
⋯5 lines
25 }
26 }(response.Body)
27 resp, err := io.ReadAll(response.Body)
28 if err != nil {
29 return nil, err
30 }
31 result := modules.BindWrapperResult{}
32 err = json.Unmarshal(resp, &result)
33 if err != nil {
34 return nil, err
⋯7 lines
42 panic(err)
43 }
44 for _, image := range images {
45 fmt.Println(image.FullUrl())
46 filePath := fmt.Sprintf("pictures/%s.json", image.Enddate[0:6])
47 err := ExportToJson(image, filePath, true)
48 if err != nil {
1MIT License
2
3Copyright (c) 2023 go-bineanshi
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
⋯6 lines
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21SOFTWARE.
No evidence locations were recorded for this file. Raw result