furl 0,1,0,0,1,0,2 travis-ci python

URL parsing and manipulation made easy.

furl

furl is a small Python library that makes parsing and manipulating URLs easy.

Python's standard urllib and urlparse modules provide a number of URL\ related functions, but using these functions to perform common URL\ operations proves tedious. Furl makes parsing and manipulating URLs\ easy.

Furl is well tested, Unlicensed in the public domain, and supports\ Python 2, Python 3, PyPy2, and PyPy3.

Code time: Query arguments are easy. Really easy.

>>> from furl import furl
>>> f = furl('http://www.google.com/?one=1&two=2')
>>> f.args['three'] = '3'
>>> del f.args['one']
>>> f.url
'http://www.google.com/?two=2&three=3'

Or use furl's inline modification methods.

>>> furl('http://www.google.com/?one=1').add({'two':'2'}).url
'http://www.google.com/?one=1&two=2'

>>> furl('http://www.google.com/?one=1&two=2').set({'three':'3'}).url
'http://www.google.com/?three=3'

>>> furl('http://www.google.com/?one=1&two=2').remove(['one']).url
'http://www.google.com/?two=2'

Encoding is handled for you. Unicode, too.

>>> f = furl('http://www.google.com/')
>>> f.path = 'some encoding here'
>>> f.args['and some encoding'] = 'here, too'
>>> f.url
'http://www.google.com/some%20encoding%20here?and+some+encoding=here,+too'
>>> f.set(host=u'ドメイン.テスト', path=u'джк', query=u'☃=☺')
>>> f.url
'http://xn--eckwd4c7c.xn--zckzah/%D0%B4%D0%B6%D0%BA?%E2%98%83=%E2%98%BA'

Fragments also have a path and a query.

>>> f = furl('http://www.google.com/')
>>> f.fragment.path.segments = ['two', 'directories']
>>> f.fragment.args = {'one':'argument'}
>>> f.url
'http://www.google.com/#two/directories?one=argument'

Or get fancy.

>>> f = furl('http://www.google.com/search?q=query#1')
>>> f.copy().remove(path=True).set(host='taco.com')
...  .join('/pumps.html').add(fragment_path='party').url
'http://taco.com/pumps.html#party'

API

See more furl magic and examples in furl's API document, API.md.

Installation

Installing furl with pip is easy.

$ pip install furl

Related Repositories

awesome-python-cn

awesome-python-cn

Python资源大全中文版,包括:Web框架、网络爬虫、模板引擎、数据库、数据可视化、图片处理等,由伯乐在线持续更新。 ...

URI.js

URI.js

Javascript URL mutation library ...

awesome-perl

awesome-perl

A curated list of awesome Perl frameworks and libraries. Come on Pull Requests! ...

MSImageMovieEncoder

MSImageMovieEncoder

Encode a movie using images (CGBitmapContext, CVPixelBuffer) on iOS 4.1 and abov ...

te-url-snippets

te-url-snippets

A set of TextExpander snippets for getting and transforming the URLs of current ...


Top Contributors

gruns medecau msabramo suligap wbolster slick666 TkTech jmcarp

Releases

-   v0.5.2 zip tar
-   v0.5.1 zip tar
-   v0.5 zip tar
-   0.5.3 zip tar