示例#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
 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