允许获取来自多个先前 URL 的 HTML。有时这需要获取需要 cookie 或 HTTP 引荐来源网址才能获取特定页面的网页。
项目描述
欢迎来到 HTML 跳转
- 作者:
丹尼尔·佩雷斯·拉达 <@dperezrada>
什么?
允许获取来自多个先前 URL 的 HTML。有时这需要获取需要 cookie 或 HTTP 引荐来源网址才能获取特定页面的网页。
先决条件
你会需要:
httplib2
http://socksipy.sourceforge.net/(如果你想使用代理)
要运行测试,您还需要:
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 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 8491722577a206530b09b80ea741e64fe3d96df8ac2e9c3683eb00f43a2ba5cf |
|
| MD5 | e1b850e7a3e0c175c01ea53305bddf1d |
|
| 布莱克2-256 | 143696a45ddfca6766c29d18860072d0eb1f6b96c12eea6467e07008bda90857 |