gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

Raise HTTP Error if HTTP status code is not equal to 200 #117

Closed woxcab closed 8 years ago

woxcab commented 8 years ago

I offer raise the exception if the HTTP code is not equal to 200 because this warns about an unexpected content.

woxcab commented 8 years ago

It is strange. If I run in python 2.7.10 with beautifulsoup 3.2.1

from pyquery import PyQuery as pq

d = pq('<meta><head><title>Hello</head><body onload=crash()>Hi all<p>', parser='soup')
assert str(d) == '<html><meta/><head><title>Hello</title></head><body onload="crash()">Hi all<p/></body></html>'

then I don't get any AssertionError, but Travis got it.

gawel commented 8 years ago

Travis use 2.7.9

woxcab commented 8 years ago

Same problem was in the previous build: https://travis-ci.org/gawel/pyquery/builds/83374284

gawel commented 8 years ago

right... and nothing related to this test in the previous commit... let say your PR is ok, thanks

woxcab commented 8 years ago

@gawel, Is it possibly better to replace condition resp.status_code != 200 to 200 <= resp.status_code < 300 like same situation processing in the urllib (both in python 2.* and python 3.*)? Because all codes 2XX have success sense: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success .

gawel commented 8 years ago

done