Skip to main content

允许获取来自多个先前 URL 的 HTML。有时这需要获取需要 cookie 或 HTTP 引荐来源网址才能获取特定页面的网页。

项目描述

欢迎来到 HTML 跳转

作者
  • 丹尼尔·佩雷斯·拉达 <@dperezrada>

什么?

允许获取来自多个先前 URL 的 HTML。有时这需要获取需要 cookie 或 HTTP 引荐来源网址才能获取特定页面的网页。

先决条件

你会需要:

要运行测试,您还需要:

  • lxml

例子

没有代理

from html_jumping import HtmlJumping
handler = HtmlJumping()
urls = [
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET'
    },
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET',
        'body': {
            'term': 'html_jumping',
            ':action': 'search',
            'submit': 'search'
        }
    }
]
received_header, received_content = handler.get(urls)

带代理

允许您使用 HTTP 代理,您需要安装 socksipy 库。

from html_jumping import HtmlJumping
handler = HtmlJumping()
urls = [
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET'
    },
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET',
        'body': {
            'term': 'html_jumping',
            ':action': 'search',
            'submit': 'search'
        }
    }
]
received_header, received_content = handler.get(
    urls,
    proxy_info = {'host': '127.0.0.1', 'port': '8081'}
)

带有永久标题

这将在每次调用中发送标题“Accept-Language”。

from html_jumping import HtmlJumping
handler = HtmlJumping()
urls = [
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET'
    },
    {
        'url': 'http://pypi.python.org/pypi',
        'method': 'GET',
        'body': {
            'term': 'html_jumping',
            ':action': 'search',
            'submit': 'search'
        }
    }
]
received_header, received_content = handler.get(
    urls,
    permanent_headers = {'Accept-Language': 'es, en-cl;q=0.5'}
)

测试

>> 鼻子测试

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

html_jumping-0.2.4.tar.gz (3.7 kB 查看哈希)

已上传 source