Introduction to Python and Embedded Tunneled HTTP

Python is a high-level scripting language that combines interpretability, compilation, interactivity, and object-oriented.
Python is designed to be highly readable. Compared with other languages, it often uses English keywords and some punctuation marks in other languages. It has more distinctive grammatical structures than other languages.

  • Python is an interpreted language:  this means that there is no compilation part of the development process. Similar to PHP and Perl languages.
  • Python is an interactive language:  this means that you can   execute code directly after a Python prompt >>> .
  • Python is an object-oriented language:  This means that Python supports an object-oriented style or programming technique in which code is encapsulated in objects.
  • Python is a beginner's language: Python is a great language for beginning programmers, supporting a wide range of application development, from simple word processing to WWW browsers to games.

Python features

  • 1. Easy to learn: Python has relatively few keywords, simple structure, and a well-defined syntax, making it easier to learn.
  • 2. Easy to read: Python code is more clearly defined.
  • 3. Easy to maintain: Python's success lies in its source code is quite easy to maintain.
  • 4. An extensive standard library: One of Python's greatest strengths is its rich library, cross-platform, and compatible with UNIX, Windows, and Macintosh.
  • 5. Interactive mode: Supported by interactive mode, you can input the language to execute the code and get the result from the terminal, and interactively test and debug code fragments.
  • 6. Portability: Based on its open source nature, Python has been ported (that is, made to work) to many platforms.
  • 7. Extensible: If you need a key piece of code that runs quickly, or want to write some algorithms that you don't want to open, you can use C or C++ to complete that part of the program, and then call it from your Python program.
  • 8. Database: Python provides interfaces to all major commercial databases.
  • 9. GUI programming: Python supports GUI can be created and ported to many system calls.
  • 10. Embeddable:  You can embed Python into C/C++ programs, allowing users of your programs to obtain "scripting" capabilities.
#! -*- encoding:utf-8 -*-

    import requests

    # 要访问的目标页面
    targetUrl = "http://ip.hahado.cn/ip"

    # 代理服务器
    proxyHost = "ip.hahado.cn"
    proxyPort = "39010"

    # 代理隧道验证信息
    proxyUser = "username"
    proxyPass = "password"

    proxyMeta = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {
        "host" : proxyHost,
        "port" : proxyPort,
        "user" : proxyUser,
        "pass" : proxyPass,
    }

    proxies = {
        "http"  : proxyMeta,
        "https" : proxyMeta,
    }

    resp = requests.get(targetUrl, proxies=proxies)

    print resp.status_code
    print resp.text

Guess you like

Origin blog.csdn.net/weixin_73725158/article/details/130334350