批处理之家's Archiver

happy886rr 发表于 2017-11-14 12:36

控制台淘宝咸鱼第三方 咸鱼.EXE

淘宝咸鱼关闭了在电脑客户端上的搜索功能,因此咸鱼.EXE有必要存在。它能不安装咸鱼app,就能在电脑上使用咸鱼搜索功能。
用法:[code]
咸鱼 [待搜索关键词]
[/code]源码(请自行编译)[code]#include <stdio.h>
#include <windows.h>

// 定义标准行长
#define LINE_BUFF_SIZE 4096

// 定义帮助说明
#define HELP_INFORMATION "\
咸鱼 V1.0 - PC端咸鱼搜索工具\n\
使用:\n\
    咸鱼 [关键词]\n"

// 获取咸鱼PC端关键词搜索地址
int GetSaltedfishURL(char* keyWords)
{
        // 过滤保护
        if(strlen(keyWords) > LINE_BUFF_SIZE / 4)
        {
                fputs("Your key words is too long\n", stdout);
        }

        // 开辟内存
        char* keyEncode = (char*)malloc(LINE_BUFF_SIZE * sizeof(char));
        char* commandLine = (char*)malloc(LINE_BUFF_SIZE * sizeof(char));

        // 编码关键词
        char* ptr = keyEncode;
        while(*keyWords)
        {
                sprintf(ptr, "%%%02X", (unsigned char)(*keyWords));
                keyWords += 1, ptr += 3;
        }

        // 组合地址
        sprintf(commandLine, "%s%s", "start https://s.2.taobao.com/list/list.htm?q=", keyEncode);
        printf("%s\n", commandLine);

        // 打开网址链接
        system(commandLine);
       
        // 释放内存
        free(keyEncode);
        free(commandLine);
        return 0;
}

// MAIN主函数
int main(int argc, char** argv)
{
        // 参数不足,则抛出使用说明
        if(argc != 2)
        {
                fputs(HELP_INFORMATION, stdout);
                return 1;
        }

        // 执行核心函数
        GetSaltedfishURL(argv[1]);
        return 0;
}
[/code]

0000 发表于 2017-11-14 21:26

[i=s] 本帖最后由 0000 于 2017-11-14 21:28 编辑 [/i]

然而你忽略了bat的实力
咸鱼.bat 329B[code]@echo off
setlocal enabledelayedexpansion
2>nul (
set /p keyword=要找什么?
set /p _=!keyword!<nul >#
del $
for %%# in (#) do fsutil file createnew $ %%~z#
set URL=https://s.2.taobao.com/list/list.htm?q=
for /f "tokens=2" %%# in ('fc /b # $') do if %%# NEQ # set URL=!URL!%%%%#
del #
del $
start "" "!URL!"
)[/code]

潇洒的小夜 发表于 2021-7-19 14:33

Get到一个新知识。
改成适合自己的[code]
@echo off
setlocal enabledelayedexpansion
echo 1.百度 2.淘宝 3.BatHome
choice /c 123
if %errorlevel%==1 set URL=https://www.baidu.com/s?wd=
if %errorlevel%==2 set URL=https://s.taobao.com/search?q=
if %errorlevel%==3 set "URL=http://zhannei.baidu.com/cse/search?s=1324540215625407466&entry=1&ie=gbk&q="
echo.
2>nul (
:keyword
set /p keyword=要找什么?
if "!keyword!" EQU "" echo keyword不能为空&goto :keyword
set /p _=!keyword!<nul >#
if exist $ del $
for %%# in (#) do fsutil file createnew $ %%~z# >nul
for /f "tokens=2" %%# in ('fc /b # $') do if %%# NEQ # set URL=!URL!%%%%#
del #
del $
start "" "!URL!"
)[/code]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.