abcfy2 / getComic

Download tencent comic-下载腾讯漫画
http://my.oschina.net/abcfy2/blog/294668
197 stars 77 forks source link

picJsonPage is empty #3

Closed markx closed 9 years ago

markx commented 9 years ago

It gets empty picJsonPage, thus json.loads(picJsonPage) raises exception.

abcfy2 commented 9 years ago

Ok. Maybe tencent comic has changed its page structure. I'll fix this issue, wait please.

abcfy2 commented 9 years ago

I've found the reason. Because the picJsonPage url like http://pad.ac.qq.com/View/mGetPicHash?id=512991&cid=27 must request with cookie, otherwise it will return nothing.

So I will parse the cookie, it may take some times.

abcfy2 commented 9 years ago

Bug fixed. Please check 535702b710093f314a83cda80175fe590990848c

Cookie must contains ac_refer=.

Please checkout the latest code and try again.

Windows bundle package is uploading.

markx commented 9 years ago

Good job! May I ask you how you found the reason and what tools did you use?

abcfy2 commented 9 years ago

Chrome F12 developer tools and Firefox firebug add-on is my friends.

Also, the command tool curl is an awesome tool.

Curl can simulate and fake the browser request, it's helpful when debugging the request headers.

When I use curl -v http://pad.ac.qq.com/View/mGetPicHash?id=512991&cid=27, returns nothing, but chrome works well. So I compare the headers between curl and chrome, and finally I've found curl -v -H 'Cookie:xxxxxxxxxxxx(copy from chrome)' can get the json string. Then I know must request with Cookie. But the cookie string is too long, so I use firefox and open firebug to check the cookie. After flush all cookies, I've found that when the cookie add the ac_refer field, picjsonpage will return json string.

After all, use curl to verify.

curl -v -H 'Cookie: ac_refer=http://pad.ac.qq.com/Comic/comicInfo/id/512991' 'http://pad.ac.qq.com/View/mGetPicHash?id=512991&cid=27'

and it works.

markx commented 9 years ago

Cool! Thanks.