刮peekyou.com(具有POST方法) [英] Scrape peekyou.com ( having POST METHOD)

查看:73
本文介绍了刮peekyou.com(具有POST方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看我得到的输出我正在尝试刮除 peekyou.com ,这是一种人民搜索引擎.他们使用php的POST方法.我使用请求库的 requests.post 方法来抓取结果.

Please see the output which I am getting I am trying to scrape peekyou.com which is kind of peoples search engine. They use POST method of php.I am using requests.post method of requests library to scrape the results .

假设某人的名字是约翰·科斯塔"那么目标网址将是:peekyou.com/john_coasta

suppose a persons name is "john coasta" then the target url would be : peekyou.com/john_coasta

import requests
import json


payload = { 'formdata' : {'md5': '4a9050a569e0f7d862b771926f7abc57',
             'asynchronous': 'true'}

}
req = requests.post('https://www.peekyou.com/shantanu_sharma',
                 data = payload,
                  headers={ 'X-Requested-With': 'XMLHttpRequest',
                           'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
                           'referer': 'https://www.peekyou.com/shantanu_sharma',
                            'server':'Apache/2.4.33 (FreeBSD) OpenSSL/1.0.2k-freebsd mod_fastcgi/mod_fastcgi-SNAP-0910052141'


}
                   )
print(req.content)

尽管我得到了HTML格式的完整结果,但我想要的结果却被编码为(我需要对o/p 进行解码),例如:\ n \ t(HTML标记{ 令人惊讶的是,这是实际结果 }).我不经常使用POST请求.请给我一些解决方案.

although I am getting the full result in HTML form , the result which I am seeking for is encoded(I need decoded o/p) in the characters like :\n\t ( inside every HTML tag {surprisingly this is the actual result}).I didn't use POST requests frequently. Please provide me some solution.

预先感谢

推荐答案

我要搜索的结果编码为:\ n \ t

the result which I am seeking for is encoded in the characters like :\n\t

响应是否为空,因为您做错了什么?当我打开该网站时,我发现它使用了很多Cookie,但您没有使用任何Cookie.如果您确定自己的操作方式正确,请使用Chrome开发者工具之类的工具来查看之后发生的情况发出此帖子请求(使用浏览器),查看浏览器是否正在解码/编码/发送cookie/等.您收到空白响应,因为我认为:未编码,服务器正在向您发送此消息,因为您在发帖请求中做错了事(根据我之前遇到的事情!)

maybe the response is blank becuase you are doing something wrong? when i opened that site, I found that it uses a lot of Cookies,but you are not using any cookies.If you are sure that you are doing everything in correct way ,then use a tool like Chrome dev tools to see what happens after making this post requests (using the browser) ,see if the browser is decoding/encoding/sending cookies/etc. You are getting Blank response ,as i think :it is not encoded,the server is sending you this because you are doing something wrong in your post request(according to something i faced before!)

这篇关于刮peekyou.com(具有POST方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆