Giter Site home page Giter Site logo

pyquery's Introduction

pyquery: a jquery-like library for python

Build Status

pyquery allows you to make jquery queries on xml documents. The API is as much as possible similar to jquery. pyquery uses lxml for fast xml and html manipulation.

This is not (or at least not yet) a library to produce or interact with javascript code. I just liked the jquery API and I missed it in python so I told myself "Hey let's make jquery in python". This is the result.

The project is being actively developed on a git repository on Github. I have the policy of giving push access to anyone who wants it and then reviewing what they do. So if you want to contribute just email me.

Please report bugs on the github issue tracker.

Quickstart

You can use the PyQuery class to load an xml document from a string, a lxml document, from a file or from an url:

>>> from pyquery import PyQuery as pq
>>> from lxml import etree
>>> import urllib
>>> d = pq("<html></html>")
>>> d = pq(etree.fromstring("<html></html>"))
>>> d = pq(url=your_url)
>>> d = pq(url=your_url,
...        opener=lambda url, **kw: urlopen(url).read())
>>> d = pq(filename=path_to_html_file)

Now d is like the $ in jquery:

>>> d("#hello")
[<p#hello.hello>]
>>> p = d("#hello")
>>> print(p.html())
Hello world !
>>> p.html("you know <a href='http://python.org/'>Python</a> rocks")
[<p#hello.hello>]
>>> print(p.html())
you know <a href="http://python.org/">Python</a> rocks
>>> print(p.text())
you know Python rocks

You can use some of the pseudo classes that are available in jQuery but that are not standard in css such as :first :last :even :odd :eq :lt :gt :checked :selected :file:

>>> d('p:first')
[<p#hello.hello>]

pyquery's People

Contributors

andrewwang43 avatar asottile avatar blag avatar cclauss avatar cuppster avatar dowski avatar gawel avatar gotcha avatar homm avatar jcushman avatar kisiel avatar kveretennicov avatar kxxt avatar liquancss avatar livibetter avatar louis0616 avatar neumond avatar olauzanne avatar pablobm avatar simonsapin avatar simonwjackson avatar ssmerche avatar suhailv avatar timgates42 avatar twz915 avatar vthriller avatar whybin avatar woxcab avatar yodalee avatar yuji38kwmt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyquery's Issues

Case sensitivity issues using css selectors

I have a valid html where there's a

<link rel="SHORTCUT ICON">

element, with capital letters in the attribute value.

selecting with .find('link[rel="shortcut icon"]') should find this element. However, it does not:

>>> from pyquery import PyQuery as pq
>>> a = pq('<html><head><link rel="SHORTCUT ICON"></head></html>')
>>> a.find('link[rel="shortcut icon"]')
[]

With jQuery and JavaScript, it succeeds:

a = $('<div><link rel="SHORTCUT ICON"></div>')
[<div>​…​</div>​]
a.find('link[rel="shortcut icon"]')
[<link rel=​"SHORTCUT ICON">​]

Please fix this.

PEP 8 compliance

Can we have PEP 8 compliant method name aliases, similar to what is done here, but the other way around?

QuickStart does not work.

The first line:

d("#hello")
[<p#hello.hello>]

I get this... using python 2.7.5
have requests loaded.

from pyquery import PyQuery as pq
d = pq(' ')
print d

print d.html()

d('#hello')
[]

HTML markup errors cause PyQuery to break Unicode text

I noticed an interesting problem using pyquery 1.2.4 with Python 3.3.0 on OS X 10.8:

>>> from pyquery import PyQuery as PQ
>>> PQ("<div>").html("<p>\N{SNOWMAN}</p>").html()
'<p>☃</p>'
>>> PQ("<div>").html("<p>\N{SNOWMAN}</>").html()
'<p>â\x98\x83&gt;</p>'
>>> PQ("<div>").html("<p>\N{SNOWMAN}").html()
'<p>â\x98\x83</p>'
>>> 

I believe the underlying problem is the chunk of pyquery's fromstring implementation where an XML parse error will change the parser to lxml.html's fromstring or parse:

            try:
                result = getattr(etree, meth)(context)
            except etree.XMLSyntaxError:
                result = getattr(lxml.html, meth)(context)

This is probably the same bug as https://bugs.launchpad.net/lxml/+bug/1002581 and the fix is the same, albeit ugly:

>>> from pyquery import PyQuery as PQ
>>> from lxml.html import HTMLParser, fromstring
>>> UTF8_PARSER = HTMLParser(encoding='utf-8')
>>> PQ("<div>").html(PQ(fromstring("<p>\N{SNOWMAN}", parser=UTF8_PARSER))).html()
'<p>☃</p>'

Support for .make_links_absolute()

Anonymous created an issue 2008-12-15

It would be great to have built-in support for calling .make_links_absolute() - something I find I need in order to make the most of pyquery for screen scraping.

Comments (8):

Olivier Lauzanne changed status to resolved

Sounded like a good idea. So I did it. I is available on the trunk, it will be on the next release that I will make this week. I think there are still things that could be done for making it better for screen scrapping: - make it possible to use the BeautifulSoup parser (I think it's compatible with lxml so it wouldn't be a problem) - make it possible to use auth and headers

2008-12-16

Fantastic, thanks!

2008-12-16

I have just tested this and while it works for hyperlinks it doesn't resolve other links in the document (as lxml's make_links_absolute does). I see how you've implemented it - could you expand your implementation or use lxml's native one?

http://codespeak.net/lxml/lxmlhtml.html#working-with-links provides details of its features and support.

2008-12-16
pbowyer

changed status to open

2008-12-17

Any progress on this?

2009-05-25

Found this when wondering why .make_links_absolute() doesn't make img src="" tags absolute. Please add absolute paths for img src="" as well!

Thanks, Seth

2009-07-24

Sorry I lost track of this issue. The problem with using the xml make_links_aboslute is that it will not work with the xml parser ... So I see no way of fixing it easily ...

2009-07-28

I have included this in my code, when document is loaded

    from urllib import basejoin
          for attr in ( "src", "href" ):
              def abs_url(i,el):
                  if not re.match("^\s*https?://", S(el).attr[attr]):
                      S(el).attr[attr]= basejoin(self.url , S(el).attr[attr])
              S("[%s]" % attr).each(abs_url)

all caps html tags do not work?

If I run the below, it cannot find the text of "TITLE"

from pyquery import PyQuery as pq
p = pq(u'<HTML><HEAD><TITLE>TEST</TITLE></HEAD></HTML>\n')
test = p("TITLE").text()
print test => None

But if i make all of the html tags lowercase, it works just fine.

from pyquery import PyQuery as pq
p = pq(u'<html><head><title>TEST</title></head></html>\n')
test = p("TITLE").text()
print test => TEST

or am i doing something wrong?

returns duplicates if context is a PyQuery object

Antti Kaihola created an issue 2010-02-09

Consider this example:

>>> doc = PyQuery('<div><div><p/></div></div>')
>>> doc('div p')
[<p>]
>>> divs = doc('div')
>>> divs.__class__
<class 'pyquery.pyquery.PyQuery'>
>>> doc('p', divs)
[<p>, <p>]

If the context divs was a plain sequence of elements, this would be unavoidable.

But since divs is a PyQuery object, we could modify the code to preserve its selector ("div") and extend it with the filtering selector ("p").

The selector div p would be executed by lxml, and no duplicates would be returned.

Open by filename fails on Python 3

I ran into a problem loading files with PyQuery on Python 3.3 :

$ python
Python 3.3.0 (default, Oct 22 2012, 11:17:43) 
>>> from pyquery import PyQuery as pq
>>> pq(filename="index.html")
[None]
>>> from lxml.html import parse
>>> parse("index.html")
<lxml.etree._ElementTree object at 0x108a72f38>
>>> pq(parse("index.html").getroot())
[<html>]

Is filename expected to work? I noticed that it's listed on http://pythonhosted.org/pyquery/ in the quickstart but not in the full API listing.

Copyright

Hi,

The LICENSE.txt and other headers file contain a copyright for Olivier Lauzanne [email protected] but no one with your name Gawel, is it a missing ?

d('option[value=1]') fails

illume created an issue 2012-06-22

This works:

>>> d=pyquery.pyquery.PyQuery("<option value='1'>")
>>> d('option[value="1"]')
[<option>]

This doesn't work, but should (it works in jquery):

>>> d=pyquery.pyquery.PyQuery("<option value='1'>")
>>> d('option[value=1]')
... ERROR...

PyQuery breaking with cssselect

Traceback (most recent call last):

  File "adapters.py", line 160, in _update
    result = j.get()

  File "/mnt/home1/home/pippaprod/webapps/pippa.prod/deployment/pippa/webapp/libs/rockspawn/rockspawn.py", line 125, in _spawn
    result = self.func(*self.args, **self.kwargs)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/Django-1.5-py2.6.egg/django/db/transaction.py", line 223, in inner
    return func(*args, **kwargs)

  File "adapters.py", line 188, in add_update
    return self._add_update(*args, **kwargs)

  File "adapters.py", line 237, in _add_update
    results = j.get()

  File "/mnt/home1/home/pippaprod/webapps/pippa.prod/deployment/pippa/webapp/libs/rockspawn/rockspawn.py", line 125, in _spawn
    result = self.func(*self.args, **self.kwargs)

  File "adapters.py", line 549, in scrape_page
    content = self.extract_content(data=fdata, url=url)

  File "adapters.py", line 730, in extract_content
    thumb = pq(i)("img:first").attr('src')

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/pyquery-1.2.4-py2.6.egg/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/pyquery-1.2.4-py2.6.egg/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/pyquery-1.2.4-py2.6.egg/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/cssselect-0.8-py2.6.egg/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/cssselect-0.8-py2.6.egg/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/cssselect-0.8-py2.6.egg/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/cssselect-0.8-py2.6.egg/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/cssselect-0.8-py2.6.egg/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))

  File "/mnt/home1/home/pippaprod/venv/lib/python2.6/site-packages/pyquery-1.2.4-py2.6.egg/pyquery/cssselectpatch.py", line 19, in xpath_first_pseudo
    xpath.add_post_condition('position() = 1')

AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'

Any ideas?

Cal

UnicodeEncodeError

python: 2.7.3
pyquery: master
cssselect: 0.8.0

from pyquery import PyQuery as pq
doc = pq([])
doc._css_to_xpath(u'a:contains("我")') 
# => u"descendant-or-self::a[contains(text(), '\u6211')]"

doc._css_to_xpath(u'a:contains("我") span')

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    doc._css_to_xpath(u'a:contains("我") span')
  File "...pyquery/pyquery.py", line 227, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "...cssselect-0.8-py2.7.egg/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "...cssselect-0.8-py2.7.egg/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "...cssselect-0.8-py2.7.egg/cssselect/xpath.py", line 210, in selector_to_xpath
    return (prefix or '') + _unicode(xpath)
  File "...pyquery/cssselectpatch.py", line 35, in __unicode__
    return str(self).decode('utf-8')
  File "...pyquery/cssselectpatch.py", line 29, in __str__
    path = str(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u6211' in position 20: ordinal not in range(128)

PyQuery .children() method wrong behavior

html = """ <div> <a href="#">text1<img src="abc"/>text2</a> <a href="#">text3<img src="xyz"/>text4</a> </div> """

tree = pq(html)

for a in tree('a'): a = pq(a) print a.children()

Prints:

    <img src="abc"/>text2
    <img src="xyz"/>text4

Instead of:

    text1<img src="abc"/>text2
    text3<img src="xyz"/>text4

pyquery.test.TestWebScrapping failure

Source compiled.

  • Testing of dev-python/pyquery-1.2.4 with CPython 3.2...
    PYTHONPATH=build-3.2/lib nosetests --verbosity=1
    ..........................................................................F...........F......

FAIL: test_post (pyquery.test.TestWebScrapping)

Traceback (most recent call last):
File "/mnt/gen2/TmpDir/portage/dev-python/pyquery-1.2.4/work/pyquery-1.2.4/pyquery/test.py", line 574, in test_post
self.assertEqual(d('input[name=q]:last').val(), 'foo')
AssertionError: None != 'foo'


Ran 93 tests in 8.419s

also

  • Testing of dev-python/pyquery-1.2.4 with CPython 2.7...
    PYTHONPATH=build-2.7/lib nosetests --verbosity=1
    .............................................................................F...........F......

pyquery- version 1.2.4
pyquery # python -V Python 2.7.3; Python 3.2.3

eq(-1) not working

version: 1.2.3

>>> a = '<ul><li>1</li><li>2</li></ul>'
>>> from pyquery import PyQuery
>>> doc = PyQuery(a)
>>> doc('li').eq(-1).text()
>>> doc('li').eq(-2).text()
'1'

So i suppose it maybe a bug.

Python2 and unicode strings cause creation instead of kicking off a .find

To re-use the example from the docs:

    >>> d("#hello")
    [<p#hello.hello>]
    >>> d(u"#hello")
    [<p>]

It's a hell of a problem when you use future.unicode_literals and the exact same code works differently in your tests than it does in ipython. Had me tearing my hair out for a bit.

Fixed in my PR and I also updated the boolean logic in that piece to use grouping parens instead of backslashes for line continuation as was done elsewhere in the file.

jQuery selector ':hidden' not supported

The jQuery pseudo-class :hidden is not currently supported. Assuming a PyQuery instance pq that has already been initialized with an HTML document, each of these calls will throw the error:

pq(':input').not_(':button, :submit, :reset, :hidden')
pq(':input').not_(':hidden')
pq(':hidden')

=>

ExpressionError: The pseudo-class :hidden is unknown

There's a way to implement your own logic for this sort of operation, as a workaround. I'll add that as a follow-up once I figure out how to do it accurately, and then maybe that 'workaround' could actually wind up being the implementation.

Inconsistent between direct url and saved contents.

PyQuery can be construct from an url or the content text. I used to think that the two modes should be same. But I found that in some situation it give me different results.

Here is my example:

from urllib2 import urlopen 
from pyquery import PyQuery
import unittest

class MyTestCase(unittest.TestCase):
    def test_pyquery(self):
        url = "http://www.ncbi.nlm.nih.gov/pubmed?term=(Biomarker%5BTitle%2FAbstract%5D)%20AND%20kidney%5BTitle%2FAbstract%5D"
        filters = [".rprt .title", ".rprt .desc", ".rprt .jrnl", ".rprt .title a", ".rprt .rprtid > dt+dd"]

        pq1 = PyQuery(url=url) # Construct from URL directly.
        pq2 = PyQuery(urlopen(url).read()) # Construct from the content of same page.

        for i in filters:
            self.assertEqual(len(pq1.find(i)), len(pq2.find(i)), "Inconsistent for '%s'" % i)

if __name__ == '__main__':
    unittest.main()

For most filters it works fine but for ".rprt .title a" it give me different result. Construction from URL give the correct answer and construction from the saved content cannot find out result.
I am working in Python2.7 and the PyQuery 1.2.4
I

PyQuery([]).text() should return an empty string.

Right now PyQuery([]).text() (calling .text() on an empty element set) returns None. It would make more sense to return an empty string.

This is annoying because it makes writing checks more complicated: 'foo' in bar.text() fails with argument of type 'NoneType' is not iterable if bar is empty, you have to write 'foo' in (bar.text() or '').

HTML elements screwed up when replacing within

Hi, I have a constructed html with a valid markup. When I replace an element within, the markup seems to 'reparse' itself, causing a faulty result. A command line example, where the &lt; element gets converted to a < element:

>>> import pyquery
>>> a = pyquery.PyQuery('<p>asdasd<a><img src="a/b"></a> asd &#13;asd &lt;img dd\nddddd</p>')
>>> print a
<p>asdasd<a><img src="a/b"/></a> asd &#13;asd &lt;img dd
ddddd</p>
>>> a.html()
u'asdasd<a><img src="a/b"/></a>asd&#13;asd &lt;img dd\nddddd'
>>> b = a.find('img')
>>> print b
<img src="a/b"/>
>>> a.find('a').replaceWith('%s' % b)
[<a>]
>>> print a
<p>asdasd<img src="a/b"/> asd &#13;asd <img dd="" ddddd=""/></p>
>>> a.html()
u'asdasd<img src="a/b"/> asd &#13;asd <img dd="" ddddd=""/>'

Note that I cant use replaceWith with a pyquery element, as it raises an error described in #9

lxml 3.1.0 is used.

Pyquery abbreviates <iframe> when .html() is called

Hi,

I have trouble with parsing and displaying code like::

<html>
  <head>
    <title>foo</title>
 </head>
 <body>
    <iframe src="http://www.google.com></iframe>
    <h2>google iframe</h2>
 </body>
</html>

if i do

  from pyquery import PyQuery
  pq=PyQuery(html)
  pq.html()

the <iframe> will appear as <iframe src="http://www.google.com" /> since there is no content in the iframe tag. Thus the resulting html does not render properly in browsers.

As a workaround .outerHtml() seems to work.

failure to locate elements

Lane Stevens created an issue 2012-07-18

I have include two files. The first file is a proper subset of the second. In the first file, the p and div elements are not found. In the second file the p and div elements are correctly found.

This issue was found in using PyQuery via WebTest but it fails when using PyQuery directly. The version in use is 1.2.1.

Example:

from pyquery import PyQuery
f = open('f1','r')
s = f.read()
f.close()
d = PyQuery(s)
print len(d('p')) #should be 1 for both files

Files at https://bitbucket.org/olauzanne/pyquery/issue/54/failure-to-locate-elements

i found a bugs

code:

document=jQuery(url='http://club.autohome.com.cn/bbs/forum-c-153-1.html')
len(document('.content div:eq(3)').html())// ok,has content
len(document('.content div:eq(4)').html())// bug,no content,why?????

the eq(0),eq(1),eq(2),eq(3)can find content, .content has more then four div, but eq(4)can't find, why???

:not() selector throws error with multiple conditions

The :not() selector works fine for single conditions, e.g.

doc.find('dt:not([class$="code"])')

But throws a SelectorSyntaxError: Expected ')', got <DELIM ',' at 22> error if there's a comma in the expression.

doc.find('dt:not([class$="code"], [class$="number"])')

I'm afraid I'm just flagging this up; haven't looked through the code to find out why.

(Also thanks for making this - I was struggling to traverse a (changeable) doc in BeautifulSoup before I found PyQuery, and life is now much better. :)

Selecting only first level children

How to select only first level children of #container? Looks like > is not supported

<div id="container">
    <div>
    </div>
    <div>
           <div></div>
    </div>
</div>

d('#container > div')

collections of strings are unprintable

dwt created an issue 2012-06-05

If you use code like this

print someCollection.map(lambda index, each: PyQuery(each).text())

it explodes as it can't deal with the fact that the pyquery collection only contains strings.

is_() is broken

is_() method does not work like jQuery one. It seems that it matches both current and child elements. Example:

>>> from pyquery import PyQuery as pq
>>> html = '<p class="one">hello <span class="two">world</span></p>'
>>> pq(html).is_('.two')
True

Selectors with empty pseudo classes don't work

Philipp Moeller created an issue 2012-09-28

pyquery borks, e.g., on the following filter:

filter(lambda i: PyQuery(this).hasClass("memitem\\\\:"))

As far as I can tell this is true for every other place a selector is used. Trying other escape sequences such as
: does not work either.

Erroneous html parsing

Hi, when i try to parse a html string with an image in it, the text after the image element is appended the original image tag. Tested in python command line:

>>> import pyquery
>>> a = pyquery.PyQuery('<p>asdasd<img src="a/b">asdasdddddddd</p>')
>>> print a
<p>asdasd<img src="a/b"/>asdasdddddddd</p>
>>> a.find('img')
[<img>]
>>> print a.find('img')
<img src="a/b"/>asdasdddddddd

the parser behind pyquery is lxml 3.1.0.

Suggestions?

.replaceWith(PyQuery element) raises error

Anonymous created an issue 2012-09-07

Using .replaceWith(PyQuery element) raises an error. This is in pyquery-1.2.1 from PyPI.

from pyquery import PyQuery as pq
root = pq("""<root><child/></root>""")
replace = pq("""<replace/>""")
child = root.find('child')
child.replaceWith(replace)

# Raises
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 1174, in replaceWith
    value(i, element) + (element.tail or ''))
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 247, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 221, in __init__
    xpath = self._css_to_xpath(selector)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 232, in _css_to_xpath
    selector = selector.replace('[@', '[')
AttributeError: 'int' object has no attribute 'replace'

Doctest failures

Doctests in README.rst fail with all versions of Python.
I use PyQuery 1.2.5.

$ nosetests-3.3
Doctest: README.rst ... FAIL
...
======================================================================
FAIL: Doctest: README.rst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.3/doctest.py", line 2154, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
nose.proxy.AssertionError: Failed doctest test for README.rst
  File "/tmp/pyquery-1.2.5/README.rst", line 0

----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 34, in README.rst
Failed example:
    d = pq(url=your_url)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.3/doctest.py", line 1287, in __run
        compileflags, 1), test.globs)
      File "<doctest README.rst[5]>", line 1, in <module>
        d = pq(url=your_url)
    NameError: name 'your_url' is not defined
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 35, in README.rst
Failed example:
    d = pq(url=your_url,
           opener=lambda url, **kw: urlopen(url).read())
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.3/doctest.py", line 1287, in __run
        compileflags, 1), test.globs)
      File "<doctest README.rst[6]>", line 1, in <module>
        d = pq(url=your_url,
    NameError: name 'your_url' is not defined
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 37, in README.rst
Failed example:
    d = pq(filename=path_to_html_file)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.3/doctest.py", line 1287, in __run
        compileflags, 1), test.globs)
      File "<doctest README.rst[7]>", line 1, in <module>
        d = pq(filename=path_to_html_file)
    NameError: name 'path_to_html_file' is not defined
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 41, in README.rst
Failed example:
    d("#hello")
Expected:
    [<p#hello.hello>]
Got:
    []
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 44, in README.rst
Failed example:
    print(p.html())
Expected:
    Hello world !
Got:
    None
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 46, in README.rst
Failed example:
    p.html("you know <a href='http://python.org/'>Python</a> rocks")
Expected:
    [<p#hello.hello>]
Got:
    []
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 48, in README.rst
Failed example:
    print(p.html())
Expected:
    you know <a href="http://python.org/">Python</a> rocks
Got:
    None
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 50, in README.rst
Failed example:
    print(p.text())
Expected:
    you know Python rocks
Got:
    None
----------------------------------------------------------------------
File "/tmp/pyquery-1.2.5/README.rst", line 57, in README.rst
Failed example:
    d('p:first')
Expected:
    [<p#hello.hello>]
Got:
    []

hasClass seems to match for child elements

Matt Goodall

JS ...

> f = $('<div><div class="hentry"></div></div>')
> f.hasClass("hentry")
false

Python ...

>>> f = pq('<div><div class="hentry"></div></div>')
>>> f.hasClass("hentry")
True

PyQuery HTML Parsing

Hello! I have encountered an issue with how PyQuery parses HTML, specifically the "doctype" tag. With this short string of HTML, behavior changes depending on whether the tag is upper case or lower case. When I use the "DOCTYPE" tag, I am unable to use the text_content method because it is not there (other methods are also missing) . I am using python 2.6.7, pyquery 1.2.4, and lxml 3.1.2. See below:

>>> lower_case = PyQuery('<!doctype html><title>Foo Bar</title>')('title')[0]
>>> upper_case = PyQuery('<!DOCTYPE html><title>Foo Bar</title>')('title')[0]
>>> lower_case
<Element title at 0x10b597050>
>>> upper_case
<Element title at 0x10b9ad640>
>>> len(dir(lower_case))
88
>>> len(dir(upper_case))
66
>>> dir(lower_case)
['__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_init', '_label__del', '_label__get', '_label__set', 'addnext', 'addprevious', 'append', 'attrib', 'base', 'base_url', 'body', 'clear', 'cssselect', 'drop_tag', 'drop_tree', 'extend', 'find', 'find_class', 'find_rel_links', 'findall', 'findtext', 'forms', 'get', 'get_element_by_id', 'getchildren', 'getiterator', 'getnext', 'getparent', 'getprevious', 'getroottree', 'head', 'index', 'insert', 'items', 'iter', 'iterancestors', 'iterchildren', 'iterdescendants', 'iterfind', 'iterlinks', 'itersiblings', 'itertext', 'keys', 'label', 'make_links_absolute', 'makeelement', 'nsmap', 'prefix', 'remove', 'replace', 'resolve_base_href', 'rewrite_links', 'set', 'sourceline', 'tag', 'tail', 'text', 'text_content', 'values', 'xpath']
>>> dir(upper_case)
['__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '_init', 'addnext', 'addprevious', 'append', 'attrib', 'base', 'clear', 'extend', 'find', 'findall', 'findtext', 'get', 'getchildren', 'getiterator', 'getnext', 'getparent', 'getprevious', 'getroottree', 'index', 'insert', 'items', 'iter', 'iterancestors', 'iterchildren', 'iterdescendants', 'iterfind', 'itersiblings', 'itertext', 'keys', 'makeelement', 'nsmap', 'prefix', 'remove', 'replace', 'set', 'sourceline', 'tag', 'tail', 'text', 'values', 'xpath']

hierarchy selectors not working for 'not_'

elijahr created an issue 2009-12-20

html = """<html>
<body>
<ul>
<li>C</li>
<li>D</li>
</ul>
<div>
<ul>
<li>E</li>
<li>F</li>
</ul>
</div>
</body>
</html>"""

import pyquery
q = pyquery.PyQuery(html)
ul = q.find('ul').not_('div > ul')

print ul
#<ul><li>C</li><li>D</li></ul><ul><li>E</li><li>F</li></ul>
# should be printing:
# <ul><li>C</li><li>D</li></ul>

Comments:

elijahr

    print ul.eq(1).is_('div > ul')
    # False
    # should print:
    # True

The scope of this bug is larger than the not_ method; the selected elements' context is lost, so that any further filtering on a PyQuery object cannot be done using selectors that reference parent elements.
2009-12-20

why pyquery add some strange characters to my html?

I used pyquery to replace a node, the code is like this:

pq = pyquery.PyQuery(html, parser = "html")
pq('#header').replaceWith(header)
fp = open('tmp.html', 'wb')
fp.write(str(pq))

but this code add some characters to my html, for example it replace

<!--/*--><![CDATA[/*><!--*/

with

&amp;amp;amp;amp;amp;lt;!--/*--&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt![CDATA[/*&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;!--*/

is this a bug of pyquery?

id selector with dot in the name fails

(Pdb) pq('.widget select')
<select#form.backend> pq('#form.backend')
[]

The corresponding HTML:

 <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en">                    <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />            <base href="http://localhost:8080/Plone/" /><!--[if lt IE 7]></base><![endif]-->                <link rel="alternate" data-kss-base-url="kss-base-url" href="http://localhost:8080/Plone/" />      <link rel="stylesheet" type="text/css" media="screen" href="http://localhost:8080/Plone/portal_css/Sunburst%20Theme/member-cachekey-900c269cf01764a1e096f36a09f25b5f.css" />    <link rel="stylesheet" type="text/css" href="http://localhost:8080/Plone/portal_css/Sunburst%20Theme/base-cachekey-356024a83ac2b2addcb0f329d1d3c239.css" />    <style type="text/css" media="screen">@import url(http://localhost:8080/Plone/portal_css/Sunburst%20Theme/resourceplone.app.jquerytools.dateinput-cachekey-76c71caca209f279ce8fdad46f0557f9.css);</style>    <link rel="stylesheet" type="text/css" media="all" href="http://localhost:8080/Plone/portal_css/Sunburst%20Theme/ploneCustom-cachekey-101b3f5afa9656523a6a16ea1461e56b.css" />      <link rel="stylesheet" data-rel="kinetic-stylesheet" type="text/kss" href="http://localhost:8080/Plone/portal_kss/Sunburst%20Theme/resourcetinymce.ksstinymce-cachekey-5c1d068948e1ac2c198cb51073458d9c.kss" />    <link rel="stylesheet" data-rel="kinetic-stylesheet" type="text/kss" href="http://localhost:8080/Plone/portal_kss/Sunburst%20Theme/at-cachekey-1cb5f7cb67a483dbd9d34d0a476e29eb.kss" />      <script type="text/javascript" src="http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/resourceplone.app.jquery-cachekey-72870daa59a3b40bee32e77877067638.js"></script>    <script type="text/javascript" src="http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/sarissa-cachekey-323c1bc9929846d51e2da9d475a0b87e.js"></script>    <script type="text/javascript" src="http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/table_sorter-cachekey-da182581d1ee6ddbdb12cfc572238895.js"></script><title>Plone site</title>            <link rel="author" href="http://localhost:8080/Plone/author/" title="Author information" />    <link rel="shortcut icon" type="image/x-icon" href="http://localhost:8080/Plone/favicon.ico" />    <link rel="apple-touch-icon" href="http://localhost:8080/Plone/touch_icon.png" />    <link rel="search" href="http://localhost:8080/Plone/@@search" title="Search this site" />                                                                                <meta name="viewport" content="width=device-width, initial-scale=0.6666, maximum-scale=1.0, minimum-scale=0.6666" />        <meta name="generator" content="Plone - http://plone.org" />    </head><body class="template-cpc-controlpanel portaltype-plone-site site-plone icons-on" dir="ltr"><div id="visual-portal-wrapper">        <div id="portal-top" class="row"><div class="cell width-full position-0">            <div id="portal-header">    <p class="hiddenStructure">  <a accesskey="2" href="http://nohost#content">Skip to content.</a> |  <a accesskey="6" href="http://nohost#portal-globalnav">Skip to navigation</a></p><div id="portal-personaltools-wrapper"><p class="hiddenStructure">Personal tools</p><dl class="actionMenu deactivated" id="portal-personaltools">    <dt class="actionMenuHeader">    <a id="user-name" href="http://localhost:8080/Plone/useractions">test_user_1_</a>  </dt>  <dd class="actionMenuContent">    <ul>        <li id="personaltools-dashboard">            <a href="http://localhost:8080/Plone/dashboard">Dashboard</a>        </li>        <li id="personaltools-preferences">            <a href="http://localhost:8080/Plone/@@personal-preferences">Preferences</a>        </li>        <li id="personaltools-plone_setup">            <a href="http://localhost:8080/Plone/@@overview-controlpanel">Site Setup</a>        </li>        <li id="personaltools-logout">            <a href="http://localhost:8080/Plone/logout">Log out</a>        </li>    </ul>  </dd>  </dl></div><div id="portal-searchbox">    <form id="searchGadget_form" action="http://localhost:8080/Plone/@@search">        <div class="LSBox">        <label class="hiddenStructure" for="searchGadget">Search Site</label>        <input name="SearchableText" type="text" size="18" title="Search Site" placeholder="Search Site" accesskey="4" class="searchField" id="searchGadget" />        <input class="searchButton" type="submit" value="Search" />        <div class="searchSection">            <input id="searchbox_currentfolder_only" class="noborder" type="checkbox" name="path" value="/plone" />            <label for="searchbox_currentfolder_only" style="cursor: pointer">                only in current section            </label>        </div>        <div class="LSResult" id="LSResult"><div class="LSShadow" id="LSShadow"></div></div>        </div>    </form>    <div id="portal-advanced-search" class="hiddenStructure">        <a href="http://localhost:8080/Plone/@@search" accesskey="5">            Advanced Search&hellip;        </a>    </div></div><a id="portal-logo" title="Plone site" accesskey="1" href="http://localhost:8080/Plone">    <img src="http://localhost:8080/Plone/logo.png" alt="Plone site" title="Plone site" height="56" width="215" /></a>    <p class="hiddenStructure">Navigation</p>    <ul id="portal-globalnav"><li id="portaltab-index_html" class="selected"><a href="http://localhost:8080/Plone" title="">Home</a></li><li id="portaltab-test-folder" class="plain"><a href="http://localhost:8080/Plone/test-folder" title="">test-folder</a></li></ul></div></div>        </div>    <div id="portal-columns" class="row">        <div id="portal-column-content" class="cell width-3:4 position-1:4">            <div id="viewlet-above-content"><div id="portal-breadcrumbs">    <span id="breadcrumbs-you-are-here">Youare here:</span>    <span id="breadcrumbs-home">        <a href="http://localhost:8080/Plone">Home</a>            </span></div></div>                                          <div class="">                                            <dl class="portalMessage info" id="kssPortalMessage" style="display:none">        <dt>Info</dt>        <dd></dd>    </dl>                                            <div id="content">                                                                                                                    <a href="http://localhost:8080/Plone/plone_control_panel" id="setup-link">                Site Setup            </a> &rsaquo;        <h1 class="documentFirstHeading">Portlet Contact: Select Back-end</h1>                <div id="content-core">            <form action="http://nohost" method="post" class="edit-form enableUnloadProtection" enctype="multipart/form-data" id="zc.page.browser_form">                <input type="hidden" name="fieldset.current" value="" />                                <fieldset>                    <legend>Select Back-end</legend>                                            <div class="field">                            <label for="form.backend">                              Back-end                              <span class="fieldRequired" title="Required">                                  (Required)                              </span>                              <span class="formHelp">Select the back-end for the Contact portlets.</span>                            </label>                                                        <div class="widget"><div><div class="value"><select id="form.backend" name="form.backend" size="1" ><option value=""></option><option selected="selected" value="dummy">dummy</option></select></div><input name="form.backend-empty-marker" type="hidden" value="1" /></div></div>                        </div>                                    </fieldset>                                <div class="visualClear"><!-- --></div>                <div id="actionsView" class="formControls">                    <span class="actionButtons">                        <input type="submit" id="form.actions.save" name="form.actions.save" value="Save" class="context" />                        <input type="submit" id="form.actions.cancel" name="form.actions.cancel" value="Cancel" class="context" />                        <input type="submit" id="form.actions.436f6e66696775726520746865206261636b2d656e64" name="form.actions.436f6e66696775726520746865206261636b2d656e64" value="Configure the back-end" class="context" />                    </span>                </div>                <input type="hidden" name="_authenticator" value="362adf7a7bc72182e454037b9362b70dc40bdf05"/>            </form>                    </div>                                          </div>                                                        </div>                                  <div id="viewlet-below-content"></div>        </div>                <div id="portal-column-one" class="cell width-1:4 position-0">                                <dl class="portlet" id="portlet-prefs">    <dt class="portletHeader">        <span class="portletTopLeft"></span>        <a href="http://localhost:8080/Plone/plone_control_panel">Site Setup</a>        <span class="portletTopRight"></span>    </dt>    <dd class="portletItem">                    <strong>Plone Configuration</strong>            <ul class="configlets">                                <li>                    <a href="http://localhost:8080/Plone/prefs_install_products_form">                                                <img src="http://localhost:8080/Plone/product_icon.png" alt="" />                    Add-ons                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@calendar-controlpanel">                                                <img src="http://localhost:8080/Plone/event_icon.png" alt="" />                    Calendar                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/portal_registry">                                                <img src="http://localhost:8080/Plone/++resource++plone.app.registry/icon.png" alt="" />                    Configuration Registry                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@rules-controlpanel">                                                <img src="http://localhost:8080/Plone/contentrules_icon.png" alt="" />                    Content Rules                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@discussion-settings">                                                <img src="http://localhost:8080/Plone/discussionitem_icon.gif" alt="" />                    Discussion                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@editing-controlpanel">                                                <img src="http://localhost:8080/Plone/cut_icon.png" alt="" />                    Editing                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/prefs_error_log_form">                                                <img src="http://localhost:8080/Plone/error_log_icon.png" alt="" />                    Errors                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@filter-controlpanel">                                                <img src="http://localhost:8080/Plone/htmlfilter_icon.png" alt="" />                    HTML Filtering                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@imaging-controlpanel">                                                <img src="http://localhost:8080/Plone/image_icon.png" alt="" />                    Image Handling                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@language-controlpanel">                                                <img src="http://localhost:8080/Plone/flag-plone.png" alt="" />                    Language                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@mail-controlpanel">                                                <img src="http://localhost:8080/Plone/mail_icon.png" alt="" />                    Mail                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@maintenance-controlpanel">                                                <img src="http://localhost:8080/Plone/maintenance_icon.png" alt="" />                    Maintenance                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@markup-controlpanel">                                                <img src="http://localhost:8080/Plone/edit.png" alt="" />                    Markup                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@navigation-controlpanel">                                                <img src="http://localhost:8080/Plone/navigation_icon.png" alt="" />                    Navigation                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@search-controlpanel">                                                <img src="http://localhost:8080/Plone/search_icon.png" alt="" />                    Search                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@security-controlpanel">                                                <img src="http://localhost:8080/Plone/lock_icon.png" alt="" />                    Security                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@site-controlpanel">                                                <img src="http://localhost:8080/Plone/logoIcon.png" alt="" />                    Site                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@skins-controlpanel">                                                <img src="http://localhost:8080/Plone/skins_icon.png" alt="" />                    Themes                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/portal_tinymce/@@tinymce-controlpanel">                                                <img src="http://localhost:8080/Plone/++resource++tinymce.images/tinymce_icon.gif" alt="" />                    TinyMCE Visual Editor                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@types-controlpanel">                                                <img src="http://localhost:8080/Plone/document_icon.png" alt="" />                    Types                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/@@usergroup-userprefs">                                                <img src="http://localhost:8080/Plone/group.png" alt="" />                    Users and Groups                    </a>                </li>                                                <li>                    <a href="http://localhost:8080/Plone/manage_main">                                                <img src="http://localhost:8080/Plone/zope_icon.png" alt="" />                    Zope Management Interface                    </a>                </li>                            </ul>                <span class="portletBottomLeft"></span>        <span class="portletBottomRight"></span>    </dd>    <dd class="portletItem">                    <strong>Add-on Configuration</strong>            <ul class="configlets">                                <li>                    <a href="http://localhost:8080/Plone/@@cpc-controlpanel">                                                <img src="http://localhost:8080/Plone/++resource++collective-portlet-contact/contact.gif" alt="" />                    collective.portlet.contact Settings                    </a>                </li>                            </ul>                <span class="portletBottomLeft"></span>        <span class="portletBottomRight"></span>    </dd></dl>                    </div>                    </div>    <div id="portal-footer-wrapper" class="row">        <div class="cell width-full position-0">            <div id="portal-footer">          <p>                              The               <a href="http://plone.org">Plone<sup>&reg;</sup> Open Source CMS/WCM</a>               is               <abbr title="Copyright">&copy;</abbr>               2000-2013               by the               <a href="http://plone.org/foundation">Plone Foundation</a>               and friends.                                             Distributed under the                    <a href="http://creativecommons.org/licenses/GPL/2.0/">GNU GPL license</a>.                         </p></div><div id="portal-colophon"><div class="colophonWrapper"><ul>  <li>    <a href="http://plone.org" title="This site was built using the Plone Open Source CMS/WCM.">      Powered by Plone &amp; Python</a>  </li></ul></div></div><ul id="portal-siteactions">    <li id="siteaction-sitemap"><a href="http://localhost:8080/Plone/sitemap" accesskey="3" title="Site Map">Site Map</a></li>    <li id="siteaction-accessibility"><a href="http://localhost:8080/Plone/accessibility-info" accesskey="0" title="Accessibility">Accessibility</a></li>    <li id="siteaction-contact"><a href="http://localhost:8080/Plone/contact-info" accesskey="9" title="Contact">Contact</a></li></ul>            <div id="kss-spinner">                <img alt="" src="http://localhost:8080/Plone/spinner.gif" />            </div>        </div>    </div></div></body></html>

append/appendTo breaks on text nodes

Using pyquery 1.2.4 with Python 3.3.0 on OS X 10.8:

Python 3.3.0 (default, Oct 22 2012, 11:17:43) 
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyquery import PyQuery as PQ
>>> PQ('<div>').append('foobar').contents().appendTo(PQ('<div>'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cadams/.virtualenvs/chris.improbable.org/lib/python3.3/site-packages/pyquery/pyquery.py", line 1068, in appendTo
    value.append(self)
  File "/Users/cadams/.virtualenvs/chris.improbable.org/lib/python3.3/site-packages/pyquery/pyquery.py", line 1061, in append
    tag.extend(root)
  File "lxml.etree.pyx", line 769, in lxml.etree._Element.extend (src/lxml/lxml.etree.c:38840)
TypeError: Cannot convert lxml.etree._ElementUnicodeResult to lxml.etree._Element

Multiple test suite failures

Hi! In an effort to update pyquery to the latest version in Fedora, I'm trying to get the test suite to fully pass with the following deps:

python-restkit-4.2.1-1.fc20.noarch
python-socketpool-0.5.2-2.fc20.noarch
python-cssselect-0.8-1.fc20.noarch
python-lxml-2.3.5-1.fc18.x86_64

However, I'm hitting these errors:

======================================================================
ERROR: test_pseudo_classes (pyquery.test.TestAjaxSelector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 260, in test_pseudo_classes
    self.assertEqual(e('div:first').text(), 'node1')
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/ajax.py", line 26, in __init__
    Base.__init__(self, *args, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 19, in xpath_first_pseudo
    xpath.add_post_condition('position() = 1')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'

======================================================================
ERROR: test_remove (pyquery.test.TestManipulating)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 453, in test_remove
    val = d('a:first').html()
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 19, in xpath_first_pseudo
    xpath.add_post_condition('position() = 1')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'

======================================================================
ERROR: test_pseudo_classes (pyquery.test.TestSelector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 260, in test_pseudo_classes
    self.assertEqual(e('div:first').text(), 'node1')
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 19, in xpath_first_pseudo
    xpath.add_post_condition('position() = 1')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'

======================================================================
ERROR: test_get (pyquery.test.TestWebScrapping)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 568, in test_get
    self.assertEqual(d('input[name=q]:last').val(), 'foo')
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 25, in xpath_last_pseudo
    xpath.add_post_condition('position() = last()')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'
-------------------- >> begin captured stdout << ---------------------
<html><head><meta name="robots" content="noindex,nofollow"/><meta http-equiv="content-type" content="text/html; charset=UTF-8;charset=utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/><title>foo at DuckDuckGo</title><link rel="stylesheet" href="/s536.css" type="text/css"/><style id="DDG" type="text/css"/><link title="DuckDuckGo" type="application/opensearchdescription+xml" rel="search" href="/opensearch_ssl.xml"/><link rel="image_src" href="/assets/logo_homepage.normal.v101.png"/><link rel="apple-touch-icon" href="/assets/logo_icon128.v101.png"/><link rel="shortcut icon" href="/favicon.ico"/><script type="text/javascript">var fd,fq,it,iqa,iqm,iqs,iqq,qw,ra,rv,rad,r1hc,r1c,r2c,r3c,ric,rfq,rq,rds,rs,rt,y,y1,ti,tig,ka,kb,kc,kd,ke,kf,kg,kh,ki,kj,kk,kl,km,kn,ko,kp,kq,kr,ks,kt,ku,kv,kw,kx,ky,kz,k1,k2,k3,k4,k5,k6,k7,k8,k9,kaa,kab,kac,kad,kae,kaf,kag,kah,kai,kaj,kak,kal,kam,kan,kao,kap,kaq,kar,kas,kat,kau,kav,kaw,kax,kay,kaz,iqd,irp,locale;irp=1;fq=0;fd=1;it=0;iqa=0;iqm=0;iqs=0;iqq=0;qw=1;iqd=0;r1hc=0;r1c=0;r2c=4;r3c=0;ric=3;rq='foo';rqd="foo";rfq=0;rt='D';ra='';rv='';rad='';rds=30;rs=0;kl='';kp='';ks='';kw='';ka='';kt='';ky='';kk='';kf='';kc='';ke='';kr='';ko='';kj='';kz='';kg='';kh='';kd='';ki='';kn='';kb='';km='';ku='';kq='';kv='';kx='';k1='';k2='';k3='';k4='';k5='';k6='',k7='',k8='',k9='';kaa='';kab='';kac='';kad='';kae='';kaf='';kag='';kah='';kai='';kaj='';kak='';kal='';kam='';kan='';kao='';kap='';kaq='';kar='';kas='';kat='';kau='';kav='';kaw='';kax='';kay='';kaz='';spice_version='';locale='en_US';</script><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/><meta name="HandheldFriendly" content="true"/><meta name="apple-mobile-web-app-capable" content="no"/></head><body class="yui-skin-sam"><input id="state_hidden" name="state_hidden" type="text" size="1"/><span class="hide">Ignore this box please.</span><div id="spacing_hidden_wrapper"><div id="spacing_hidden"/></div><div id="add_to_browser" class="modal grp_modal"/><div id="add_to_browser_homepage" class="modal grp_modal"/><div id="feedback_modal" class="modal grp_modal"><h4 id="feedback_modal_title">Feedback</h4><a href="javascript:;" id="report_bad_query_link" class="icon bad" onclick="">Report Bad Results</a><span id="try_search_on_links" class="icon try" style="display: none;">Try <a target="_bangg" href="/?q=!g+foo">Google</a>, <a target="_bangb" href="/?q=!b+foo">Bing</a>, <a href="/bang.html" onclick="this.href='#';nbc();return false;">more&#8230;</a></span><a target="_help" href="feedback" class="icon ques">Other Help / Feedback</a></div><script type="text/javascript" src="/locales/en_US/LC_MESSAGES/duckduckgo-duckduckgo+sprintf+gettext+locale-simple.20130311.003843.js"/><script type="text/javascript" src="/d946.js"/><div id="header_wrapper"><div id="header"><div id="header_content_wrapper"><div id="header_content"><div class="clear"/><a tabindex="-1" href="/?t="><div id="header_logo"/></a><form id="search_form" name="x" action="/" onsubmit="return nbr()"><div id="search_elements_hidden"/><div id="search_wrapper"><input id="search_button" type="submit" tabindex="2" value=""/><a id="search_dropdown" href="javascript:;" tabindex="4" onclick="DDG.toggle('newbang');"/></div><input id="search_form_input_clear" type="button" tabindex="3" value=""/><input type="text" name="q" tabindex="1" autocomplete="off" id="search_form_input" onfocus="if ('rc' in window) {nua('nro',rc)};fq=1;" onblur="fq=0" onclick="if (this.value=='put search terms here') {this.value='';this.style.color='#000000';}" value="foo"/><select id="bang" size="2" onchange="if (ip) nbb(this);" onclick="if (!ip) nbb(this);" onblur="nbc(1);"/></form><div id="header_button_wrapper" onclick="DDG.toggle('header_button_menu')"><ul id="header_button"><li><div id="header_button_menu_wrapper"><a class="header_button_menu_item" id="header_button_menu_title" href="javascript:;">More</a><ul id="header_button_menu" class="grp_modal"><li><a href="/settings.html" tabindex="-1">Settings</a></li><li><a href="/about.html" tabindex="-1">About</a></li><li><a href="/goodies/" tabindex="-1">Goodies</a></li><li><a href="/feedback.html" tabindex="-1">Help</a></li><li class="header_button_menu_header">PRIVACY</li><li><a href="/privacy.html" tabindex="-1">Policy</a></li><li><a href="http://donttrack.us/" tabindex="-1">DontTrack</a></li><li><a href="http://dontbubble.us/" tabindex="-1">DontBubble</a></li><li><a href="http://whatisdnt.com/" tabindex="-1">WhatIsDNT</a></li><li><a href="http://fixtracking.com/" tabindex="-1">FixTracking</a></li><li class="header_button_menu_header">COMMUNITY</li><li><a href="http://duckduckhack.com/" tabindex="-1">Develop</a></li><li><a href="https://dukgo.com/" tabindex="-1">Translate</a></li><li><a href="/support.html" tabindex="-1">Support Us</a></li></ul></div></li></ul></div><div class="clear"/></div></div></div></div><div id="content_wrapper"><div id="content"><div id="side_wrapper"><div id="side_wrapper2"><div id="side"><div class="button"><script type="text/JavaScript">nib(0,'button-link add-to','','&amp;nbsp;',0,0)</script></div><div id="feedback_wrapper"><div class="button"><span id="trig_feedback_modal" class="modal_trig"/><a tabindex="-1" href="javascript:;" rel="nofollow" class="button-link" onclick="DDG.mv_elem('feedback_modal','trig_feedback_modal');DDG.toggleall('grp_modal',-1,'feedback_modal');DDG.toggle('feedback_modal');">Give feedback</a></div></div><div id="side_suggestions" class="hide"/><div id="keyboard_shortcuts" class="hide"><div class="spacer_bottom_7">Keyboard shortcuts</div>h, / &#160; &#160; search box<br/>j, &#8595; &#160; &#160; next result<br/>k, &#8593; &#160; &#160; prev result<br/>l, o, Enter &#160; &#160; go<div id="keyboard_shortcuts_more" class="spacer_top_3"><a tabindex="-1" href="javascript:;" onclick="nsh('keyboard_shortcuts_more')">More...</a></div><div id="keyboard_shortcuts_more_hidden" class="hide"><br/>Ctrl+Enter &#160; &#160; bg<br/>', v &#160; &#160; new tab<br/>d &#160; &#160; domain search<br/>t &#160; &#160; Top<br/>!, 1 &#160; &#160; !bang dropdown<br/>esc &#160; &#160; out of bangs<br/>s &#160; &#160;Did you mean<br/>r &#160; &#160; related topics<br/>m &#160; &#160; main results<br/><a target="_blank" href="http://help.duckduckgo.com/customer/portal/articles/300862"> More explanation...</a></div></div><div id="side_powered_by_wrapper" class="hide"/></div></div></div><div id="zero_click_wrapper"><div id="zero_click"><div id="zero_click_wrapper2"><div id="zero_click_abstract" style="display:none;"/><div id="zero_click_header"><div id="zero_click_heading"><h1>Meanings of Foobar</h1></div><div id="zero_click_plus_wrapper" class="icon_zero_click_header"><a href="javascript:;" onclick="nra4()" id="zero_click_plus">&#160;</a></div><div class="icon_zero_click_header"><a title="Definition" href="/?q=define+foo"><img src="/assets/icon_definition.v101.png" class="inline"/></a></div><div class="clear"/></div><div id="zero_click_topics"><div id="r2-0" class="results_disambig"><div class="icon_disambig"/><div class="links_zero_click_disambig highlight_1"><a href="/Foobar">Foobar</a>, an all-purpose placeholder name commonly used in computing</div></div><div id="r2-1" class="results_disambig"><div class="icon_disambig"><img id="i2" alt=""/></div><div class="links_zero_click_disambig highlight_1"><a href="/foobar2000">foobar2000</a>, an audio player for Microsoft Windows</div></div><div class="results_disambig"><div class="links_zero_click_disambig"><div class="zero_click_header_info">See also <hr class="horizontal_line horizontal_line_truncated"/></div></div></div><div id="r2-2" class="results_disambig"><div class="icon_disambig"/><div class="links_zero_click_disambig highlight_1"><a href="/d/FUBAR">FUBAR Meanings</a></div></div><div id="r2-3" class="results_disambig"><div class="icon_disambig"><img id="i3" alt="" class="img_disambig"/></div><div class="links_zero_click_disambig highlight_1"><a href="/flame_fougasse">Foo gas</a> - A flame fougasse is a type of mine which uses an explosive charge to project burning liquid onto a target.</div></div></div><div class="clear">&#160;</div></div><div id="zero_click_abstract_stacked" class="zero_click_snippet" style="display:none;"/></div></div><div id="links_wrapper"><noscript> &#160; &#160; This page requires Javascript. Get the non-JS version <a href="https://duckduckgo.com/html/?q=foo">here</a>.</noscript><div id="did_you_means"/><div id="ads"/><div id="links"/></div><div id="powered_by_wrapper"/><div id="bottom_spacing2"> </div></div></div><script type="text/javascript">nip();</script><script type="text/javascript">tig=new YAHOO.util.ImageLoader.group('body',null,0.01);nus('',2,ga+'www.foobar2000.org.ico',30,30);nus('',3,ga+'2ebf3f96.jpg');</script><script type="text/JavaScript">function nrji() {nrj('/d.js?q=foo&amp;t=D&amp;l=us-en&amp;p=1&amp;s=0');if (!DDG.is_ad_blocked) nrj('/y.js?s=1&amp;q=foo');};if (ir) window.addEventListener('load', nrji, false);else nrji();</script><div id="z2"> </div><script type="text/JavaScript">if (ip) setTimeout('nuo(1)',500);</script><div id="z"> </div></body></html>

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: INFO: Starting new HTTP connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "GET /?q=foo HTTP/1.1" 301 178
urllib3.connectionpool: INFO: Starting new HTTPS connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "GET /?q=foo HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

======================================================================
ERROR: test_post (pyquery.test.TestWebScrapping)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 574, in test_post
    self.assertEqual(d('input[name=q]:last').val(), 'foo')
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
    for selector in selectors)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
    xpath = self.xpath(tree)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
    return method(parsed_selector)
  File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
    return method(self.xpath(pseudo.selector))
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 25, in xpath_last_pseudo
    xpath.add_post_condition('position() = last()')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'
-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: INFO: Starting new HTTP connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "POST / HTTP/1.1" 301 178
urllib3.connectionpool: INFO: Starting new HTTPS connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "GET / HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

======================================================================
FAIL: Doctest: pyquery.pyquery.PyQuery.nextAll
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for pyquery.pyquery.PyQuery.nextAll
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 434, in nextAll

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 438, in pyquery.pyquery.PyQuery.nextAll
Failed example:
    d('p:last').nextAll()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest pyquery.pyquery.PyQuery.nextAll[2]>", line 1, in <module>
        d('p:last').nextAll()
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
        result = self.__class__(*args, parent=self, **kwargs)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
        xpath = self._css_to_xpath(selector)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
        return self._translator.css_to_xpath(selector, prefix)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
        xpath = self.xpath(tree)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
        return method(parsed_selector)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
        return method(self.xpath(pseudo.selector))
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 25, in xpath_last_pseudo
        xpath.add_post_condition('position() = last()')
    AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'


======================================================================
FAIL: Doctest: pyquery.pyquery.PyQuery.prevAll
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for pyquery.pyquery.PyQuery.prevAll
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 446, in prevAll

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 450, in pyquery.pyquery.PyQuery.prevAll
Failed example:
    d('p:last').prevAll()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest pyquery.pyquery.PyQuery.prevAll[2]>", line 1, in <module>
        d('p:last').prevAll()
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
        result = self.__class__(*args, parent=self, **kwargs)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
        xpath = self._css_to_xpath(selector)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
        return self._translator.css_to_xpath(selector, prefix)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
        xpath = self.xpath(tree)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
        return method(parsed_selector)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
        return method(self.xpath(pseudo.selector))
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 25, in xpath_last_pseudo
        xpath.add_post_condition('position() = last()')
    AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'


======================================================================
FAIL: Doctest: pyquery.pyquery.PyQuery.remove_namespaces
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for pyquery.pyquery.PyQuery.remove_namespaces
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 285, in remove_namespaces

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 291, in pyquery.pyquery.PyQuery.remove_namespaces
Failed example:
    doc.remove_namespaces()
Expected:
    [<foo>]
Got:
    [<{http://example.com/foo}foo>]


======================================================================
FAIL: Doctest: pyquery.pyquery.PyQuery.xhtml_to_html
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for pyquery.pyquery.PyQuery.xhtml_to_html
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 267, in xhtml_to_html

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 274, in pyquery.pyquery.PyQuery.xhtml_to_html
Failed example:
    doc.remove_namespaces()
Expected:
    [<html>]
Got:
    [<{http://www.w3.org/1999/xhtml}html>]


======================================================================
FAIL: Doctest: 
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for 
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/docs/ajax.txt", line 0

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/docs/ajax.txt", line 42, in 
Failed example:
    print a.response.status
Expected:
    200 OK
Got:
    301 Moved Permanently

-------------------- >> begin captured logging << --------------------
restkit.client: DEBUG: Start to perform request: packages.python.org GET /pyquery/
restkit.client: DEBUG: Send headers: ['GET /pyquery/ HTTP/1.1\r\n', 'Host: packages.python.org\r\n', 'User-Agent: restkit/4.2.1\r\n', 'Accept-Encoding: identity\r\n', 'Content-Length: 0\r\n', 'Content-Type: application/octet-stream\r\n']
restkit.client: DEBUG: send body (chunked: False)
restkit.client: DEBUG: Start to parse response
restkit.client: DEBUG: Got response: (1, 1) 301 Moved Permanently
restkit.client: DEBUG: headers: [IOrderedDict([('Server', 'nginx/1.1.19'), ('Date', 'Sat, 06 Apr 2013 15:06:23 GMT'), ('Content-Type', 'text/html'), ('Content-Length', '185'), ('Location', 'http://pythonhosted.org/pyquery/')])]
restkit.client: DEBUG: return response class
--------------------- >> end captured logging << ---------------------

======================================================================
FAIL: test_replaceWith (pyquery.test.TestHTMLParser)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 492, in test_replaceWith
    assert val == expected, (repr(val), repr(expected))
AssertionError: ('u\'<div class="portlet">\\n      <a href="/toto">TestimageMy link text</a>\\n      <a href="/toto2">imageMy link text 2</a>\\n      Behind you, a three-headed HTML&amp;dash;Entity!\\n    </div>\\n    \'', '\'<div class="portlet">\\n      <a href="/toto">TestimageMy link text</a>\\n      <a href="/toto2">imageMy link text 2</a>\\n      Behind you, a three-headed HTML&amp;dash;Entity!\\n    </div>\'')

======================================================================
FAIL: test_replaceWith_with_function (pyquery.test.TestHTMLParser)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 503, in test_replaceWith_with_function
    assert val == expected, (repr(val), repr(expected))
AssertionError: ('u\'<div class="portlet">\\n      TestimageMy link text\\n      imageMy link text 2\\n      Behind you, a three-headed HTML&amp;dash;Entity!\\n    </div>\\n    \'', '\'<div class="portlet">\\n      TestimageMy link text\\n      imageMy link text 2\\n      Behind you, a three-headed HTML&amp;dash;Entity!\\n    </div>\'')

======================================================================
FAIL: Doctest: 
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for 
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/../README.rst", line 0

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/../README.rst", line 61, in 
Failed example:
    d('p:first')
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest [13]>", line 1, in <module>
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 237, in __call__
        result = self.__class__(*args, parent=self, **kwargs)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 213, in __init__
        xpath = self._css_to_xpath(selector)
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/pyquery.py", line 223, in _css_to_xpath
        return self._translator.css_to_xpath(selector, prefix)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in css_to_xpath
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 188, in <genexpr>
        for selector in selectors)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 208, in selector_to_xpath
        xpath = self.xpath(tree)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 230, in xpath
        return method(parsed_selector)
      File "/usr/lib/python2.7/site-packages/cssselect/xpath.py", line 272, in xpath_pseudo
        return method(self.xpath(pseudo.selector))
      File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/cssselectpatch.py", line 19, in xpath_first_pseudo
        xpath.add_post_condition('position() = 1')
    AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'

-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: INFO: Starting new HTTP connection (1): google.com
urllib3.connectionpool: DEBUG: "GET / HTTP/1.1" 301 219
urllib3.connectionpool: INFO: Starting new HTTP connection (1): www.google.com
urllib3.connectionpool: DEBUG: "GET / HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

======================================================================
FAIL: Doctest: 
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2201, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for 
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/docs/tips.txt", line 0

----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/docs/tips.txt", line 10, in 
Failed example:
    d('a[tabindex="-1"]').attr('href')
Expected:
    '/about.html'
Got:
    '/about'
----------------------------------------------------------------------
File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/docs/tips.txt", line 14, in 
Failed example:
    d('a[tabindex="-1"]').attr('href')
Expected:
    'http://duckduckgo.com/about.html'
Got:
    'http://duckduckgo.com/about'

-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: INFO: Starting new HTTP connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "GET / HTTP/1.1" 301 178
urllib3.connectionpool: INFO: Starting new HTTPS connection (1): duckduckgo.com
urllib3.connectionpool: DEBUG: "GET / HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

======================================================================
FAIL: test_remove_namespaces (pyquery.test.TestXMLNamespace)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lmacken/rpmbuild/BUILD/pyquery-1.2.4/pyquery/test.py", line 558, in test_remove_namespaces
    self.assertEqual(repr(val), repr(expected))
AssertionError: 'None' != "'What'"

----------------------------------------------------------------------
Ran 97 tests in 2.106s

FAILED (errors=5, failures=10)

Fails when using unicode string as selector

PyQuery fails when the selector is passed as a unicode string. The following example reproduces the bug in my machine:

>>> from pyquery import PyQuery
>>> g = PyQuery("http://google.com")
>>> g("title").html()
'Google'
>>> g(u"title").html()
'title'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.