Skip to content

Commit fe8debc

Browse files
committed
添加icp查询
1 parent 357d76b commit fe8debc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.MD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ biu-cli -pnew 项目名称
3838
```shell
3939
cat ip.txt|biu-cli -pid 项目ID
4040
cat domain.txt|biu-cli -pid 项目ID
41+
```
42+
43+
- 查询备案并添加到已有项目中
44+
```shell
45+
biu-cli -icp xx公司|biu-cli -pid 项目ID
4146
```
4247

4348
- 配合https://opendata.rapid7.com/sonar.https/使用

cmd/biu-cli.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/tidwall/gjson"
1313
"log"
1414
"os"
15+
"regexp"
1516
"strings"
1617
)
1718

@@ -21,6 +22,7 @@ var (
2122
ak string
2223
pnew string
2324
pid string
25+
icp string
2426
ip string
2527
pageSize int
2628
client = resty.New()
@@ -52,6 +54,22 @@ func biuClient() *resty.Request {
5254

5355
}
5456

57+
func icpSearch() {
58+
resp, err := client.R().Get(fmt.Sprintf("https://beian.tianyancha.com/search/%s", icp))
59+
if err != nil {
60+
fmt.Print(err)
61+
}
62+
if resp.StatusCode() == 200 {
63+
reg, err := regexp.Compile(`<span class="ranking-ym" rel="nofollow">([a-z0-9-\.]+)`)
64+
if err == nil {
65+
match := reg.FindAllString(resp.String(), -1)
66+
for _, domain := range match {
67+
fmt.Println(strings.Split(domain, ">")[1])
68+
}
69+
}
70+
}
71+
}
72+
5573
func addTargetToProject(target string) {
5674
if target != "" {
5775
resp, err := biuClient().
@@ -199,6 +217,7 @@ func main() {
199217
flag.StringVar(&biu, "host", "", "biu host url: https://x.x.x.x")
200218
flag.StringVar(&pnew, "pnew", "", "biu new project name")
201219
flag.StringVar(&pid, "pid", "", "biu project id")
220+
flag.StringVar(&icp, "icp", "", "备案名称查询域名")
202221
flag.StringVar(&ip, "ip", "", "biu search ip")
203222
flag.BoolVar(&isSearch, "s", false, "biu 搜索模式")
204223
flag.IntVar(&pageSize, "l", 20, "pageSize")
@@ -218,8 +237,9 @@ func main() {
218237
searchIP(addr)
219238
}
220239

240+
} else if icp != "" {
241+
icpSearch()
221242
} else {
222-
flag.Parse()
223243
if pid == "" {
224244
if pnew == "" {
225245
listProjects()

0 commit comments

Comments
 (0)