PowerShell版小鹤形码查询

2021-10-22 • 预计阅读时间 1 分钟

小鹤有一个形码查询的网站:http://react.xhup.club/search .不喜欢每次打开网页,由于平时工作基本上离不开PowerShell,所以写了一个CLI版本的.具体如下.可以把下面的代码放到你的Profile中.之后就可以用xhup+字来反查了.

Set-Alias xhup get-xhup
# 小鹤编码查询
function get-xhup($search_word) {
    try {
        $url = "http://www.xhup.club/Xhup/Search/searchCode"
        $key_xhup = 'fjc_xhup'
	
        $encodeWord = [System.Web.HttpUtility]::UrlEncode($search_word)
	
        $ret = $key_xhup + $search_word
        $sign = get-hash($ret)
        # write-host $sign
	
        $resp = Invoke-WebRequest -Uri $url `
            -Method "POST" `
            -Headers @{
            "Accept"          = "application/json, text/plain, */*"
            "User-Agent"      = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4506.0 Safari/537.36 Edg/92.0.895.0"
            "Origin"          = "http://react.xhup.club"
            "Referer"         = "http://react.xhup.club/"
            "Accept-Encoding" = "gzip, deflate"
            "Accept-Language" = "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,pl;q=0.6,zh-TW;q=0.5,ja;q=0.4,mt;q=0.3,fr;q=0.2,ru;q=0.1,ar;q=0.1,da;q=0.1,de;q=0.1,pt;q=0.1,no;q=0.1,vi;q=0.1"
        } `
            -ContentType "application/x-www-form-urlencoded" `
            -Body "search_word=$encodeWord&sign=$sign"
	
        $data = ConvertFrom-json $resp.Content
        $dz = $data.list_dz[0]
        Write-Output "● $($dz[0]):"
        Write-Output  "● 拆分:$($dz[1])"
        Write-Output "● 首末:$($dz[2]) $($dz[3])"
        Write-Output "● 形码:$($dz[4]) $($dz[5])"
    }
    catch {
        Write-Error 请求异常
    }

可以用xhupPowerShell中反查形码.

🦄🔥>>> xhup 彩
● 彩:  cdpp:
● 拆分:丿 ⺍ 木 丿 丿 丿
● 首末:丿 丿
● 形码:p p
devPowerShell

wentao

写点代码,解决点问题。

快速抓取Emacs Org Mode

如何处理陌生系统的线上故障