本文整理汇总了Python中Foundation.NSString.stringWithContentsOfURL_方法的典型用法代码示例。如果您正苦于以下问题:Python NSString.stringWithContentsOfURL_方法的具体用法?Python NSString.stringWithContentsOfURL_怎么用?Python NSString.stringWithContentsOfURL_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation.NSString
的用法示例。
在下文中一共展示了NSString.stringWithContentsOfURL_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _fetchLists
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import stringWithContentsOfURL_ [as 别名]
def _fetchLists(self):
"""A private convenience function that uses BeautifulSoup (for parsing) and NSString (for authentication)
to make combing the HTML code from the main page of lists a bit easier."""
page = NSString.stringWithContentsOfURL_(NSURL.URLWithString_("http://%s.tadalist.com/lists" % (self.username)))
soup = BeautifulSoup(page)
rawLists = soup.findAll('li')
lists = []
for rawList in rawLists:
lists.append( TadaList(rawList.a['href'], rawList.a.contents[0], self) )
return lists
示例2: _fetchItems
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import stringWithContentsOfURL_ [as 别名]
def _fetchItems(self, force=True):
"""Private method that fetches attributes off of the list's page, parses the HTML (with BeautifulSoup),
and then creates TadaItems. This is called automatically when a user requests the 'items' of a TadaList."""
page = NSString.stringWithContentsOfURL_(NSURL.URLWithString_(self._url()))
soup = BeautifulSoup(page)
lis = soup.findAll('li')
items = []
for li in lis:
items.append(TadaItem(li.form.contents[-1].strip(), li['id'][5:], self))
self.items = items
return self.items