# BrowserMob Proxy
BrowserMob Proxy allows you to manipulate HTTP requests and responses, capture HTTP content, and export performance data as a [HAR file](http://www.softwareishard.com/blog/har-12-spec/).
BMP works well as a standalone proxy server, but it is especially useful when embedded in Selenium tests.
The latest version of BrowserMob Proxy is 2.1.2, powered by [LittleProxy](https://github.com/adamfisk/LittleProxy).
If you're running BrowserMob Proxy within a Java application or Selenium test, get started with [Embedded Mode](#getting-started-embedded-mode). If you want to run BMP from the
command line as a standalone proxy, start with [Standalone](#getting-started-standalone).
### Getting started: Embedded Mode
To use BrowserMob Proxy in your tests or application, add the `browsermob-core` dependency to your pom:
```xml
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
<version>2.1.2</version>
<scope>test</scope>
</dependency>
```
Start the proxy:
```java
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start(0);
int port = proxy.getPort(); // get the JVM-assigned port
// Selenium or HTTP client configuration goes here
```
Then configure your HTTP client to use a proxy running at the specified port.
**Using with Selenium?** See the [Using with Selenium](#using-with-selenium) section.
### Getting started: Standalone
To run in standalone mode from the command line, first download the latest release from the [releases page](https://github.com/lightbody/browsermob-proxy/releases), or [build the latest from source](#building-the-latest-from-source).
Start the REST API:
```sh
./browsermob-proxy -port 8080
```
Then create a proxy server instance:
```sh
curl -X POST http://localhost:8080/proxy
{"port":8081}
```
The "port" is the port of the newly-created proxy instance, so configure your HTTP client or web browser to use a proxy on the returned port.
For more information on the features available in the REST API, see [the REST API documentation](#rest-api).
## Changes since the 2.1-beta series
**The `browsermob-core-littleproxy` module is now `browsermob-core`**
After six beta releases, the LittleProxy implementation now supports more features and is more stable than the legacy implementation. To reflect that level of maturity and long-term support, the `browsermob-core` module now uses LittleProxy by default.
**Note about Legacy support**: In the 2.1-betas, if you were using the `ProxyServer` or `LegacyProxyServer` classes, use the `browsermob-core-legacy` module in 2.1.0 and higher.
*LittleProxy support for `LegacyProxyServer` has moved to `BrowserMobProxyServerLegacyAdapter`*. Using the LittleProxy implementation with the `LegacyProxyServer` interface is still fully supported as a means to help you transition from 2.0.0. Unlike the 2.1-beta series, the `BrowserMobProxyServer` class
no longer implements `LegacyProxyServer`; however, the `BrowserMobProxyServerLegacyAdapter` can be used to integrate legacy code with the new LittleProxy interface. You must still use the `browsermob-core-legacy` module when using the LegacyAdapter.
```java
LegacyProxyServer proxy = new BrowserMobProxyServerLegacyAdapter();
proxy.setPort(8081); // method only supported by the legacy interface
proxy.start();
```
## Changes since 2.0.0
The new [BrowserMobProxyServer class](browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxyServer.java) has replaced the legacy ProxyServer implementation. The legacy implementation is no longer actively supported; all new code should use `BrowserMobProxyServer`. We highly recommend that existing code migrate to the new implementation.
The most important changes from 2.0 are:
- [Separate REST API and Embedded Mode modules](#embedded-mode). Include only the functionality you need.
- [New BrowserMobProxy interface](browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxy.java). The new interface will completely replace the legacy 2.0 ProxyServer contract in version 3.0 and higher.
- [LittleProxy support](#littleproxy-support). More stable and more powerful than the legacy Jetty back-end.
### New BrowserMobProxy API
BrowserMob Proxy 2.1 includes a [new BrowserMobProxy interface](browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxy.java) to interact with BrowserMob Proxy programmatically. The new interface defines the functionality that BrowserMob Proxy will support in future releases (including 3.0+). To ease migration, both the legacy (Jetty-based) ProxyServer class and the new, LittleProxy-powered BrowserMobProxy class support the new BrowserMobProxy interface.
We _highly_ recommend migrating existing code to the BrowserMobProxy interface using the `BrowserMobProxyServer` class.
### Using the LittleProxy implementation with 2.0.0 code
The legacy interface, implicitly defined by the ProxyServer class, has been extracted into `net.lightbody.bmp.proxy.LegacyProxyServer` and is now officially deprecated. The new LittleProxy-based implementation will implement LegacyProxyServer for all 2.1.x releases. This means you can switch to the LittleProxy-powered implementation with minimal change to existing code ([with the exception of interceptors](#http-request-manipulation)):
```java
// With the Jetty-based 2.0.0 release, BMP was created like this:
ProxyServer proxyServer = new ProxyServer();
proxyServer.start();
// [...]
// To use the LittleProxy-powered 2.1.2 release, simply change to
// the LegacyProxyServer interface and the adapter for the new
// LittleProxy-based implementation:
LegacyProxyServer proxyServer = new BrowserMobProxyServerLegacyAdapter();
proxyServer.start();
// Almost all deprecated 2.0.0 methods are supported by the
// new BrowserMobProxyServerLegacyAdapter implementation, so in most cases,
// no further code changes are necessary
```
LegacyProxyServer will not be supported after 3.0 is released, so we recommend migrating to the `BrowserMobProxy` interface as soon as possible. The new interface provides additional functionality and is compatible with both the legacy Jetty-based ProxyServer implementation [(with some exceptions)](new-interface-compatibility.md) and the new LittleProxy implementation.
If you must continue using the legacy Jetty-based implementation, include the `browsermob-core-legacy` artifact instead of `browsermob-core`.
## Features and Usage
The proxy is programmatically controlled via a REST interface or by being embedded directly inside Java-based programs and unit tests. It captures performance data in the [HAR format](http://groups.google.com/group/http-archive-specification). In addition it can actually control HTTP traffic, such as:
- blacklisting and whitelisting certain URL patterns
- simulating various bandwidth and latency
- remapping DNS lookups
- flushing DNS caching
- controlling DNS and request timeouts
- automatic BASIC authorization
### REST API
**New in 2.1:** The REST API now supports LittleProxy. As of 2.1.0-beta-3, LittleProxy is the default implementation. (You may specify `--use-littleproxy false` to disable LittleProxy in favor of the legacy Jetty 5-based implementation.)
To get started, first start the proxy by running `browsermob-proxy` or `browsermob-proxy.bat` in the bin directory:
$ sh browsermob-proxy -port 8080
INFO 05/31 03:12:48 o.b.p.Main - Starting up...
2011-05-30 20:12:49.517:INFO::jetty-7.3.0.v20110203
2011-05-30 20:12:49.689:INFO::started o.e.j.s.ServletContextHandler{/,null}
2011-05-30 20:12:49.820:INFO::Started SelectChannelConnector@0.0.0.0:8080
Once started, there won't be an actual proxy running until you create a new proxy. You can do this by POSTing to /proxy:
[~]$ curl -X POST http://localhost:8080/proxy
{"port":8081}
or optionally specify your own port:
[~]$ curl -X POST -d '
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【目标受众】: 本项目适合IT相关专业各种计算机技术的源代码和项目资料,如计科、人工智能、通信工程、自动化和电子信息等的在校学生、老师或者企业员工下载使用。 也适合小白学习进阶,可以用作比赛项目、可以进行项目复刻去参加同赛道比赛。 【资源内容】: 源码与竞赛资料:教育部认可的大学生竞赛备赛资料代码、源码、竞赛总结。 功能与质量保证:这个资源库是一个宝贵的学习平台,有助于他们深入了解计算机技术的原理和应用。这些源码经过测试和验证,可以直接运行,方便学生快速上手并开始实践。 【应用场景】: 竞赛准备:适用于各种教育部认可的竞赛,如全国电子设计大赛、全国大学生智能汽车竞赛等,他们可以借助这些资料了解竞赛的规则、要求和技巧。 学习与项目开发:可以用作毕设、课设、作业和竞赛项目的开发基础,可以使用这些源码作为项目开发的基础,快速构建出具有竞争力的作品。 【互动与交流】: 资料鼓励下载和使用这些资源,并欢迎学习者进行沟通交流、互相学习、共同进步。这种互动式的学习方式有助于形成良好的学习氛围,促进知识的共享和传播,为计算机相关专业的学习者提供了一个全面的学习和发展平台。
资源推荐
资源详情
资源评论
收起资源包目录
竞赛资料源码-人工智能创新创业大赛.zip (153个子文件)
____pycache__ 4KB
__chromedriver 4KB
__cookie 4KB
__data 4KB
__file 4KB
__free_ip 4KB
__mafengwo 4KB
__qunaer 4KB
__result 4KB
browsermob-proxy.bat 3KB
browsermob-proxy 781B
ca-certificate-rsa.cer 1KB
ca-certificate-ec.cer 737B
__config.cfg 4KB
config.cfg 3KB
chromedriver 14.94MB
canteen_ner.csv 1.45MB
travel_ner.csv 995KB
scenic_ner.csv 334KB
hotel_ner.csv 217KB
product_set.csv 66KB
product.csv 29KB
__canteen_ner.csv 4KB
__travel_ner.csv 4KB
__hotel_ner.csv 4KB
__scenic_ner.csv 4KB
__product.csv 4KB
proxy.har 8KB
__proxy.har 4KB
scarpy.ipynb 938KB
dataloader.ipynb 320KB
spider.ipynb 30KB
spider_ip.ipynb 20KB
demo.ipynb 16KB
Spacyfood.ipynb 11KB
spider.ipynb 8KB
single_pass.ipynb 4KB
__spider.ipynb 4KB
__spider.ipynb 4KB
__scarpy.ipynb 4KB
__spider_ip.ipynb 4KB
__demo_selenium.ipynb 4KB
__combine_data.ipynb 4KB
__Spacyfood.ipynb 4KB
combine_data.ipynb 4KB
demo_selenium.ipynb 2KB
browsermob-dist-2.1.4.jar 20.86MB
browsermob-core-2.1.4-javadoc.jar 479KB
browsermob-rest-2.1.4-javadoc.jar 111KB
browsermob-core-2.1.4-sources.jar 103KB
browsermob-rest-2.1.4-sources.jar 16KB
cookie_js.js 39KB
cookie_js.js 35KB
__cookie_js.js 4KB
__cookie_js.js 4KB
canteen_combine.json 912KB
canteen_all.json 736KB
canteen.json 736KB
hotel_combine.json 678KB
hotels_all.json 607KB
hotel.json 607KB
hotel_all.json 531KB
canteen.json 413KB
similar_catering.json 246KB
similar_hotel.json 116KB
hotel.json 110KB
scienic.json 93KB
scienic.json 93KB
data.json 18KB
__canteen_all.json 4KB
__hotel_all.json 4KB
__canteen.json 4KB
__hotels_all.json 4KB
__hotel.json 4KB
__scienic.json 4KB
__data.json 4KB
__hotel.json 4KB
__similar_hotel.json 4KB
__similar_catering.json 4KB
__canteen.json 4KB
__hotel.json 4KB
__scienic.json 4KB
__hotel_combine.json 4KB
__canteen_combine.json 4KB
__train_food.json 4KB
train_food.json 2KB
hotel.json 165B
server.log 344KB
bmp.log 343KB
__server.log 4KB
__bmp.log 4KB
README.md 28KB
README.md 45B
ca-keystore-rsa.p12 3KB
ca-keystore-ec.p12 1019B
__SpacyNer.py 4KB
__HugNer.py 4KB
__lbsmap.py 4KB
__SpacyNer.py 4KB
__gdmap.py 4KB
共 153 条
- 1
- 2
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功