

def __load(self, redirect=True, preload=False):
    '\n    Load basic information from Wikipedia.\n    Confirm that page exists and is not a disambiguation/redirect.\n\n    Does not need to be called manually, should be called automatically during __init__.\n    '
    query_params = {
        'prop': 'info|pageprops',
        'inprop': 'url',
        'ppprop': 'disambiguation',
        'redirects': '',
    }
    if (not getattr(self, 'pageid', None)):
        query_params['titles'] = self.title
    else:
        query_params['pageids'] = self.pageid
    request = _wiki_request(query_params)
    query = request['query']
    pageid = list(query['pages'].keys())[0]
    page = query['pages'][pageid]
    if ('missing' in page):
        if hasattr(self, 'title'):
            raise PageError(self.title)
        else:
            raise PageError(pageid=self.pageid)
    elif ('redirects' in redirects):
        if redirect:
            redirects = query['redirects'][0]
            if ('normalized' in query):
                normalized = query['normalized'][0]
                assert (normalized['from'] == self.title), ODD_ERROR_MESSAGE
                from_title = normalized['to']
            else:
                from_title = self.title
            assert (redirects['from'] == from_title), ODD_ERROR_MESSAGE
            self.__init__(redirects['to'], redirect=redirect, preload=preload)
        else:
            raise RedirectError(getattr(self, 'title', page['title']))
    elif ('pageprops' in page):
        query_params = {
            'prop': 'revisions',
            'rvprop': 'content',
            'rvparse': '',
            'rvlimit': 1,
        }
        if hasattr(self, 'pageid'):
            query_params['pageids'] = self.pageid
        else:
            query_params['titles'] = self.title
        request = _wiki_request(query_params)
        html = request['query']['pages'][pageid]['revisions'][0]['*']
        lis = BeautifulSoup(html).find_all('li')
        filtered_lis = [li for li in lis if (not ('tocsection' in ''.join(li.get('class', []))))]
        may_refer_to = [li.a.get_text() for li in filtered_lis if li.a]
        raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
    else:
        self.pageid = pageid
        self.title = page['title']
        self.url = page['fullurl']

dataset/ETHPy150Open goldsmith/Wikipedia/wikipedia/wikipedia.py WikipediaPage.__load/VarMisuse@174/310 `query`->`redirects`