nausheenfatma / python-wikitools

Automatically exported from code.google.com/p/python-wikitools
0 stars 0 forks source link

Query frees for infinite loop & handling wiki errors #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. site = wiki.Wiki("http://en.wikipedia.org/w/api.php")
   params = {'action':'query',
      'titles' : 'deep lake water cooling',
      'prop':'extracts|images|imageinfo',
      'format' : 'json',
      'iiprop' : 'parsedcomment|url|dimensions|size',
      'generator':'images', 
      'exlimit':10 
      }
  req = wiki.api.APIRequest(site, params) 
2. Searching for two separated words cause the API to freeze, I can get error 
or no result work

What is the expected output? What do you see instead?
based on the wikipedia document it should give me back this result 
http://en.wikipedia.org/w/api.php?action=query&titles=deep%20lake%20water%20cool
ing:&format=jsonfm

{
    "query": {
        "pages": {
            "-2": {
                "ns": 0,
                "title": "Doesntexist",
                "missing": ""
            },
            "-1": {
                "title": "Talk:",
                "invalid": ""
            },
            "15580374": {
                "pageid": 15580374,
                "ns": 0,
                "title": "Main Page"
            }
        }
    }
}
What version of the product are you using? On what operating system?

I have the latest version of wikitools 
Please provide any additional information below.

Original issue reported on code.google.com by Basel.Ma...@gmail.com on 5 Jul 2013 at 2:14

GoogleCodeExporter commented 8 years ago
Note that wikitools has moved to GitHub. Except for currently outstanding bug 
reports, all new development work will happen there - 
https://github.com/alexz-enwp/wikitools

To fix the specific problem in this case, you need to set the 'redirects' param 
to automatically resolve redirects

params = {'action':'query',
      'titles' : 'deep lake water cooling',
      'prop':'extracts|images|imageinfo',
      'format' : 'json',
      'iiprop' : 'parsedcomment|url|dimensions|size',
      'generator':'images', 
      'exlimit':10,
      'redirects':''
}

This should do what you want. 

The more general problem is that most generator queries with an empty result 
set return nothing.

I've fixed this in 
https://github.com/alexz-enwp/wikitools/commit/22a8b920b53f2afc83bf2621d4e802d33
e201f06

It now "properly" returns [] as an APIListResult object

Original comment by MrZmanwiki@gmail.com on 6 Nov 2013 at 5:17

GoogleCodeExporter commented 8 years ago
Issue 50 has been merged into this issue.

Original comment by MrZmanwiki@gmail.com on 7 Dec 2013 at 10:41