> url (string) – Instead of code and fam, does try to get a Site based on the URL. Still requires that the family supporting that URL exists.
> From this I get the impression that pywikibot has a list of mediawiki sites that it recognises, and if a site isn't on that list, it won't work.

I think you are right, I believe the url parameter is only an alternative way to refer to an existing family, not add a new site.

You will need to create a family file like this under pywikibot/families:


from pywikibot import family


class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)

        self.name = 'localhost'

        self.langs = {
                'en': 'localhost',
        }

        self.content_id = "mainContent"

    def scriptpath(self, code):
        return ''

    def path(self, code):
        return '/mw/index.php'

    def apipath(self, code):
        return '/mw/api.php'


--
Yusuke

On Mon, Feb 12, 2018 at 9:45 AM, Phil Hunt <cabalamat@gmail.com> wrote:

Hi,

I'm playing with pywikibot. I have a mediawiki on my local machine, for testing.

I want to extract the text from a page in it, the page being <http://127.0.0.1/mw/index.php/Cabalamat:Test_Article>,
so I have tried this code:

localMw = pywikibot.Site(
    url="http://127.0.0.1/mw/index.php/")
page = pywikibot.Page(localMw, "Cabalamat:Test_Article")

however, I get this error message:

Traceback (most recent call last):
  File "simple.py", line 27, in <module>
    url="http://127.0.0.1/mw/index.php/")
  File "/home/phil/sproj/wfbots/venv/local/lib/python2.7/site-packages/pywikibot/__init__.py", line 1214, in Site
    raise SiteDefinitionError("Unknown URL '{0}'.".format(url))
pywikibot.exceptions.SiteDefinitionError: Unknown URL 'http://127.0.0.1/mw/index.php/'.
<class 'pywikibot.exceptions.SiteDefinitionError'>
CRITICAL: Closing network session.



url (string) – Instead of code and fam, does try to get a Site based on the URL. Still requires that the family supporting that URL exists.


From this I get the impression that pywikibot has a list of mediawiki sites that it recognises, and if a site isn't on that list, it won't work.

Is that correct or am I misunderstanding something?



--
Phil Hunt, <cabalamat@gmail.com>


_______________________________________________
pywikibot mailing list
pywikibot@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot