예제 #1
0
 def recently_changed_pages(timestamp):
     changes = site.recentchanges(start=timestamp,
                                  namespace=0,
                                  toponly=1,
                                  type='edit|new',
                                  dir='newer',
                                  show='!minor|!redirect|!anon|!bot')
     for page in changes:
         title = page.get('title')
         if title:
             doc = db.get(title)
             doc_revid = doc.get('parse', {}).get('revid') if doc else None
             revid = page.get('revid')
             if doc_revid == revid:
                 continue
             yield title
예제 #2
0
def redirects_to(site, from_title):
    """ Same as mwclient.page.Page.redirects_to except it returns page and fragment
    in a named tuple instead of just target page
    """
    info = site.api('query', prop='pageprops', titles=from_title,
                    redirects='')['query']
    if 'redirects' in info:
        for page in info['redirects']:
            if page['from'] == from_title:
                return Redirect(page=mwclient.page.Page(site, page['to']),
                                fragment=page.get('tofragment', u''))
        return None
    else:
        return None
예제 #3
0
파일: scrape.py 프로젝트: korhoj/mwscrape
def redirects_to(site, from_title):
    """ Same as mwclient.page.Page.redirects_to except it returns page and fragment
    in a named tuple instead of just target page
    """
    info = site.api('query', prop='pageprops', titles=from_title, redirects='')['query']
    if 'redirects' in info:
        for page in info['redirects']:
            if page['from'] == from_title:
                return Redirect(
                    page=mwclient.page.Page(site, page['to']),
                    fragment=page.get('tofragment', u'')
                )
        return None
    else:
        return None
예제 #4
0
 def set_iter(self, data):
     for page in six.itervalues(data['query']['pages']):
         if page['title'] == self.page.name:
             self._iter = iter(page.get(self.list_name, ()))
             return
     raise StopIteration
예제 #5
0
파일: listing.py 프로젝트: stanta/mwclient
 def set_iter(self, data):
     for page in six.itervalues(data['query']['pages']):
         if page['title'] == self.page.name:
             self._iter = iter(page.get(self.list_name, ()))
             return
     raise StopIteration