简体   繁体   English

在python中捕获http调用和标头

[英]capture http calls and headers in python

We are testing videos in our website, and in order to play it should authenticate the user, get the authorization for the device he is playing and so on, check his entitlements etc., we have many varieties of network and video types to test. 我们正在网站上测试视频,为了播放该视频,应该对用户进行身份验证,获得他正在播放的设备的授权等等,检查其权利等,我们可以测试多种网络和视频类型。 And I am in process of writing script which checks one of those calls are working fine for all type of videos. 而且我正在编写脚本,以检查这些调用之一对于所有类型的视频是否工作正常。 Which is a POST call and need to build the param/data to post. 这是一个POST调用,需要构建要发布的参数/数据。 Theres no direct way of getting one of the param value and this is how we do currently. 没有直接的方法可以获取参数值之一,这就是我们目前的做法。 We go to browser and play the video. 我们转到浏览器并播放视频。 Open the dev tools like firebug and capture the param value from the request header of the same call and use it in my script for rest of other 100 different calls to verify programmatically. 打开诸如firebug之类的开发工具,并从同一调用的请求标头中捕获参数值,然后在我的脚本中将其用于其他100个不同调用的其余部分,以编程方式进行验证。

Is there a way in python to do the steps which we are manually doing? python中是否有一种方法可以执行我们正在手动执行的步骤? like open a url and capture all the calls which happens at the background just like how firebug does? 就像打开网址并捕获所有在后台发生的调用一样,就像萤火虫一样吗?

I am trying firePython, firelogger, mechanize to see if they help . 我正在尝试firePython,firelogger,机械化看看它们是否有帮助。 but I have invested so much time figuring out doing this, so thought its time to approach some expert advice. 但是我花了很多时间来解决这个问题,所以我认为是时候寻求专家的建议了。

如果您没有看过Requests库,那么使用它通常会很愉快,并且可能会使您的生活更轻松。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM