允许从以前的几个url获取html。有时这是需要得到的网页,需要cookies或一个http引用,以获得特定的网页。
html_jumping的Python项目详细描述
欢迎使用HTML跳转
Author: |
|
---|
什么?
允许从以前的几个url获取html。有时这是需要得到的网页,需要cookies或一个http引用,以获得特定的网页。
示例
无代理
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'} )
测试
运行
>> nosetests