iiktn / pybing

Automatically exported from code.google.com/p/pybing
Other
0 stars 0 forks source link

Results are incorrect when bing returns an exact total result count #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For example this query:
http://api.search.live.net/json.aspx?Query=ninjas&Version=2.0&AppId=<YOUR_APP_ID
>&Sources=Web&Web.Count=50

returns an exact result count (37-40 right now, likely to change). It appears 
that pybing expects this to be >1000 always and doesn't check the actual 
returned total count. Iterating through such a query yields hundreds of 
repeated results.

Here is an example program that exposes the problem using svn trunk:

#!/usr/bin/env python
from pybing.query import WebQuery
q = WebQuery("<YOUR_APP_ID>", query="ninjas")
results = q.execute()
for result in results:
    # outputs 760 results for me = 37 actual results each occuring 20 times
    print result.title.encode('utf-8') 

Original issue reported on code.google.com by kristaps.rats@gmail.com on 4 Jan 2012 at 4:22

GoogleCodeExporter commented 8 years ago
*38 actual results each occuring 20 times

Original comment by kristaps.rats@gmail.com on 4 Jan 2012 at 4:23

GoogleCodeExporter commented 8 years ago
I am encountering this problem as well. I think the problem is in __getitem__() 
in resultset.py, in "if absolute_index not in self.results"; if I comment that 
out the code works fine and doesn't return duplicates but ONLY if you take a 
slice of results. I want all results, so I'm just giving a very large number 
(e.g. results[:99999])

Original comment by jonathan...@gmail.com on 24 Feb 2012 at 12:10

GoogleCodeExporter commented 8 years ago
Note: with this workaround, len(results) will still return MAX_RESULTS.

Original comment by jonathan...@gmail.com on 24 Feb 2012 at 12:10