# Python script to start a proxy and save the content

**URL:** <https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693>\
**Category:** help\
**Created:** [November 4, 2017, 5:55am UTC](https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693 "2017-11-04T05:55:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![willingenss](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@willingenss](https://discourse.mitmproxy.org/u/willingenss)\
**Post date:** [November 4, 2017, 5:55am UTC](https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693/1 "2017-11-04T05:55:41Z")

</div>

Hello! I have a question when using Mitmproxy, I am trying to start a proxy to catch the https request and response in my phone and save it. **Can I write a python script to start an https proxy and save the request and response text to local files**?

---

<div class="post-metadata">

**Author:** ![willingenss](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@willingenss](https://discourse.mitmproxy.org/u/willingenss)\
**Post date:** [November 4, 2017, 6:08am UTC](https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693/2 "2017-11-04T06:08:16Z")

</div>

I have already installed mitmproxy package using pip,  
but when I started a scritt, this error occurred:  
ImportError: No module named libmproxy

Can anybody give a help? (T\_T)

---

<div class="post-metadata">

**Author:** ![Gigiarum](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/gigiarum/32/278_2.png) [@Gigiarum](https://discourse.mitmproxy.org/u/Gigiarum)\
**Post date:** [November 4, 2017, 9:07am UTC](https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693/3 "2017-11-04T09:07:37Z")

</div>

Can you start only mitmproxy without any script? For a script example you can watch har dump in complex examples.  
Don’t forget to install certifcate in the phone to act correctly in https.

---

<div class="post-metadata">

**Author:** ![willingenss](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@willingenss](https://discourse.mitmproxy.org/u/willingenss)\
**Post date:** [November 4, 2017, 10:23am UTC](https://discourse.mitmproxy.org/t/python-script-to-start-a-proxy-and-save-the-content/693/4 "2017-11-04T10:23:24Z")

</div>

Thank you for your anwser!  
I can use “mitmproxy -s [sample.py](http://sample.py)” to catch the https info now~  
But I still confuse about how to write a script and use “python [sample.py](http://sample.py)” to start a https proxy 😂  
I think I need to see more example…  
Thank you again ! 😁
