Pywikipedia name wikiquote is undefined?
I am writing a bot for Wikipedia but have a problem. When I want to retrieve content from another Wikimedia site, I get an error - error-name 'wikiquote' is not defined.
This is when I run the code like this:
import wikipedia site = wikiquote.getSite()
But if I had to start with wikipedia written instead of wikicot, it works. As I understand it, it should work on other Mediawiki sites?
Help rate with gratitude!
Thanks!
a source to share
wikiquote
not defined or imported anywhere in your script. So it is clear that your code is not working.
According to the pywikipedia documentation , you need to use this instead:
import wikipedia
site = wikipedia.getSite('en', 'wikiquote')
a source to share
If you only use this for yourself, it doesn't matter, but pywikipedia bots should allow the user to control which site they are running on (and which account they are using). Users set these parameters in a file user-config.py
as described here . In this case, they installed:
family = 'wikiquote'
which should be processed by your bot. You can look at the file login.py
to see an example of using these configuration options.
a source to share