本文整理汇总了Python中element.Element.load方法的典型用法代码示例。如果您正苦于以下问题:Python Element.load方法的具体用法?Python Element.load怎么用?Python Element.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类element.Element
的用法示例。
在下文中一共展示了Element.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ud
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import load [as 别名]
def test_ud(ilist):
filter = UserDefinedFilter(ilist)
from cStringIO import StringIO
from element import Element
from media import MediaFactory,GenericMedia,List
fd = StringIO('''<TrackerList>
<Tracker publisher="th-torrent">
<Url name="login" url="http://forums.btthai.com/" method="post">
<Param name="UserName" value="%(user)s"/>
<Param name="PassWord" value="%(password)s"/>
<Param name="act" value="Login"/>
<Param name="CODE" value="01"/>
<Param name="CookieDate" value="1"/>
</Url>
<Url name="catalog" url="http://forums.btthai.com/" method="get">
<Param name="act" value="bt"/>
<Param name="func" value="browse"/>
<Filter name="main"><![CDATA[<tr>\s*<td class="[^"]+" align="center"><img src="style_images/[^/]+/cat_(?P<category>[^\.]+).[^<]+" border="0" alt="[^"]+" width="\d+" height="\d+"/></td>\s*<td class="[^"]+" align="left"><a href="(?P<link>[^"]+)">(?P<title>[^<]+)</a></td>\s*<td class="[^"]+" align="right">(?P<files>\d+)</td>\s*<td class="[^"]+" align="center">[^<]+</td>\s*<td class="[^"]+" align="center" nowrap>(?P<date>[^<]+(<br/>| )[^<]*)</td>\s*<td class="[^"]+" align="center">[^<]+</td>\s*<td class="[^"]+" align="center">\d+</td>\s*<td class="[^"]+" align="right">\d+</td>\s*<td class="[^"]+" align="right">\d+</td>\s*<td class="[^"]+" align="center"><a href="[^"]+">(?P<publisher>[^<]+)</a></td>\s*</tr>]]></Filter>
<Filter name="detail"><![CDATA[<tr><td align="left" class='pformleft'>Name</td><td class='pformright'><a href="index.php\?showtopic=\d+">(?P<description>[^<]+)</a></td></tr>\s*<tr><td align="left" class='pformleft'>Info Hash</td><td class='pformright'>[^<]+</td></tr>\s*<tr><td align="left" class='pformleft'>Download</td><td class='pformright'><a href="(?P<download>[^\?]+\?act=bt&func=download&id=\d+)">[^<]+</a></td></tr>]]></Filter>
</Url>
<Url name="logout" url="http://th-torrent.mine.nu/"/>
</Tracker>
</TrackerList>''' % {'user': user,
'password': passwd})
element = Element()
element.load(fd)
factory = MediaFactory(GenericMedia,List)
tlist = factory.from_element(element)
fd.close()
loader = TrackerLoader(tlist[0],filter)
loader.fetch().to_element().save(sys.stdout)
示例2: from_file
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import load [as 别名]
def from_file(self,file):
close_flag = 0
if type(file) == type(''):
fd = open(file,'r')
close_flag = 1
else:
fd = file
e = Element()
e.load(fd)
if close_flag:
fd.close()
return self.from_element(e)
示例3: List
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import load [as 别名]
factory.register('enclosure',rssEnclosure)
if __name__ == '__main__':
import sys
from cStringIO import StringIO
mlist = List('MediaList')
mlist.append(Generic('Media',{'title': 'test'}))
mlist.append(Series('Anime',{'title': 'Gundam Seed','episode': 1}))
fd = StringIO()
mlist.to_element().save(fd)
fd.seek(0,0)
result = fd.read()
print result
fd.seek(0,0)
element = Element()
element.load(fd)
mlist = factory.from_element(element)
fd.close()
mlist.to_element().save(sys.stdout)
fd = StringIO('''<TrackerList>
<Tracker publisher="th-torrent">
<Url name="login" url="http://th-torrent.mine.nu/" method="post">
<Param name="user" value="sugree"/>
<Param name="password" value="xxxx"/>
</Url>
<Url name="catalog" url="http://th-torrent.mine.nu/">
<Filter name="main"><![CDATA[<tr>\s*<td class="[^"]+" align="center"><img src="style_images/[^/]+/cat_(?P<category>[^\.]+).[^<]+" border="0" alt="[^"]+" width="\d+" height="\d+"/></td>\s*<td class="[^"]+" align="left"><a href="(?P<link>[^"]+)">(?P<title>[^<]+)</a></td>\s*<td class="[^"]+" align="right">(?P<files>\d+)</td>\s*<td class="[^"]+" align="center">[^<]+</td>\s*<td class="[^"]+" align="center" nowrap>(?P<date>[^<]+(<br/>| )[^<]*)</td>\s*<td class="[^"]+" align="center">[^<]+</td>\s*<td class="[^"]+" align="center">\d+</td>\s*<td class="[^"]+" align="right">\d+</td>\s*<td class="[^"]+" align="right">\d+</td>\s*<td class="[^"]+" align="center"><a href="[^"]+">(?P<publisher>[^<]+)</a></td>\s*</tr>]]></Filter>
<Filter name="detail"><![CDATA[<a href="(?P<download>[^\?]+\?act=bt&func=download&id=\d+)">]]></Filter>
</Url>
<Url name="logout" url="http://th-torrent.mine.nu/"/>