Giter Site home page Giter Site logo

-'s Introduction

-

使用Python 调用百度识图,识取本地图片并得到结果 先自己手动完成百度识图的整个过程,#5为向百度上传图片,#10为一个不知道的响应过程,#14为一个关于注册的js响应,#16同样为一个json。通过观察可知,识图的相关响应只发生在#5和#10以及#16三步。

image

利用Fiddler观察#5的请求信息,是一个post形式的请求,除了一般的headers以外,还有一个文件传输

image

(具体内容不止图中这点) 这是一个multipart/form-data请求,能够用python的requests进行模拟。具体方法参照: http://blog.csdn.net/j_akill/article/details/43560293和https://www.cnblogs.com/titan5750/p/6879114.html 返回的response中的内容如下所示

image

然后观察#10,#10的网页中已经有了guessword

image

该guessword应该就是结果了。那么只要获得#10的网址就可以获得识图的结果,也就不需要查看#16了。查看#10的request_url

image

该网址可以用到#5中返回的querySign和queryImageUrl,推测fm、uptype、result应该是不变的字符串,只剩下最后一个vs未知。查找所有js文件,在http://imgn0.bdstatic.com/image/mobile/n/static/pcdutu/static/pkg/pcdutu_*****.js中找到

image

观察后可知fm、uptype、result的确为不变的字符串(不同情况下可能不同),而vs取值来自变量u,将该js反编译以后

image

u为window.bd,这个window有可能是JavaScript 层级中的顶层对象Window,代表一个浏览器窗口或一个框架。那么这个window应该第一次打开百度识图网页的时候就确定了,打开image.baidu.com/?fr=shitu的网页,查看源代码,果然里面有一个window,且该window有一个vsid。

image

将这个vsid保存下来结合#5中获得的数据,就可以构造#10的网页,进而获得#10网页中的guessword。

-'s People

Contributors

gggfeel avatar

Watchers

 avatar

-'s Issues

运行时出现错误

目前将图片改名为“test1.jpg”,并放在py文件同一个目录下,运行后提示:
Python使用的3
Traceback (most recent call last):
File "test_baidu_stu.py", line 24, in
tmp_json=json.loads(tmp)
File "C:\Users\lijinqiang\AppData\Local\Programs\Python\Python38\lib\json_init_.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Users\lijinqiang\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\lijinqiang\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

一直在找这个工具,也尝试自己写,结果各种不懂,非常感谢您提供的这个脚本!!
麻烦问一下,这个该怎么解决?非常感谢!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.