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


Python WebPage.get_from_xpath方法代码示例

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


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

示例1: set_data

# 需要导入模块: from webpage import WebPage [as 别名]
# 或者: from webpage.WebPage import get_from_xpath [as 别名]
    def set_data(self):
        w=WebPage(htmldata=self.htmldata1)

        #find all the codes for season/year in the first html form data
        self.semesters={}
        xpath="""//*[@id="CLASS_SRCH_WRK2_STRM$35$"]/option"""
        for e in w.get_from_xpath(xpath):
            key,semester=e.text,e.get("value")
            if key.strip() and semester.strip():
                self.semesters[key]=semester

        #match up season/year to the codes we just found, if possible
        code=0
        for key in self.semesters:
            if self.season.lower() in key.lower() and str(self.year) in key:
                code=self.semesters[key]
                break

        if not code:
            print_color("Warning: failed to find season/year in search options. season='%s' year='%s'"%(self.season,self.year),COLORS.RED)
            print_d("search options",self.semesters)

        self.data={"ICFocus":"SSR_CLSRCH_WRK_ACAD_CAREER$2",
                "CLASS_SRCH_WRK2_STRM$35$":str(code),
                "SSR_CLSRCH_WRK_SUBJECT$0":self.department,
                "ICAction":"CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH",
                "SSR_CLSRCH_WRK_ACAD_CAREER$2":self.level}
开发者ID:Zulban,项目名称:zconcordia,代码行数:29,代码来源:concordia_search.py


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