当前位置: 首页>>代码示例>>Python>>正文


Python URL.by_id方法代码示例

本文整理汇总了Python中pattern.web.URL.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python URL.by_id方法的具体用法?Python URL.by_id怎么用?Python URL.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pattern.web.URL的用法示例。


在下文中一共展示了URL.by_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pages

# 需要导入模块: from pattern.web import URL [as 别名]
# 或者: from pattern.web.URL import by_id [as 别名]
       "-de", "-en", "-es", "-fr", "-it", "-nl", 
       "-shell", "stop-words", "mbsp-tags", "-dev"):
 # We include some useful pages (Penn Treebank tags, stop words) referenced in the documentation.
 if p.startswith("-"):
     p = "pattern" + p.rstrip("-")
     title = p.replace("-", ".")
 if p == "stop-words":
     title = "Stop words"
 if p == "mbsp-tags":
     title = "Penn Treebank II tag set"
 # Download the online documentation pages.
 print "Retrieving", url + p
 html = URL(url + p).download(cached=False)
 # Parse the actual documentation, we don't need the website header, footer, navigation, search.
 html = Document(html)
 html = html.by_id("content-area")
 html = html.by_class("node-type-page")[0]
 html = html.source
 html = strip_javascript(html)
 html = strip_between('<div id="navbar">', '/#navbar -->', html)
 html = strip_between('<div id="sidebar-right">', '/#sidebar-right -->', html)
 html = strip_between('<div id="footer">', '/#footer -->', html)
 html = strip_between('<a class="twitter-share-button"', '</a>', html)
 # Link to local pages and images.
 # Link to online media.
 html = html.replace('href="/pages/MBSP"', 'href="%sMBSP"' % url)                   # MBSP docs (online)
 html = re.sub('href="/pages/(pattern-examples.*?)"', 'href="%s\\1"' % url, html)   # examples (online)
 html = re.sub('href="/pages/(using-.*?)"', 'href="%s\\1"' % url, html)             # examples (online)
 html = re.sub('href="/pages/(modeling-.*?)"', 'href="%s\\1"' % url, html)          # examples (online)
 html = re.sub('href="/pages/(.*?)([#|"])', 'href="\\1.html\\2', html)              # pages (offline)
 html = html.replace('src="/media/', 'src="../g/')                                  # images (offline)
开发者ID:DevKhokhar,项目名称:pattern,代码行数:33,代码来源:update.py


注:本文中的pattern.web.URL.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。