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


Python PyQuery.encode方法代码示例

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


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

示例1: _dump_slide

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import encode [as 别名]
def  _dump_slide(slide, idx_slide, outputdir):

    html = PyQuery(slide).html();
    slide_name = '%03d.html' % idx_slide
    print "dump slide {} in dir {}".format(idx_slide, outputdir)    
    dump = open(os.path.join(outputdir,slide_name), 'w+')
    dump.write("@template:content_bare\n")
    dump.write(html.encode('utf-8','replace'))
    dump.close()
开发者ID:tiry,项目名称:reveal-js-tools,代码行数:11,代码来源:split.py

示例2: getData

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import encode [as 别名]
	def getData(self, selector):
		"""
		Return the all text in the area limitet by the selector
		"""
		tags = self.sorceCode.find(selector)
		text = PQ(tags.html()).text()
		text = text.encode(self.encoding, 'xmlcharrefreplace')
		#print text

		return text
开发者ID:jotaV,项目名称:WebCapture,代码行数:12,代码来源:session.py

示例3: PyQuery

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import encode [as 别名]
	server.sendmail(mailFrom, rcptToList, message.as_string())
	server.quit()

if '__main__' == __name__:
	configFile = 'config.cfg'
	novels = PyQuery(filename = configFile)
	message = ''
	for novel in novels('novel'):
		name = PyQuery(novel)('name').text()
		url = PyQuery(novel)('url').text()
		prefix = PyQuery(novel)('prefix').text()
		next = int(PyQuery(novel)('next').text())
		rcptToList = []
		for addr in PyQuery(novel)('emails>email'):
			rcptToList.append(PyQuery(addr).text())
		print rcptToList
		html = PyQuery(url = url)
		nextUrl = None
		for i in html('div.threadlist_title.pull_left.j_th_tit.member_thread_title_frs > a.j_th_tit'):
			if i.text.find(number2chinese(next)) != -1:
				nextUrl = prefix + PyQuery(i).attr('href')
				break
		if nextUrl:
			next += 1
			PyQuery(novel)('next').text(str(next))
			text = PyQuery(url=nextUrl)('cc:first > div:first').html()
			text = text.replace(u'<br/>', '\n').strip()
			subject = name + u' ' + u'第'+unicode(str(next))+u'章'
			send_mail('[email protected]', rcptToList, subject.encode('utf8'), text.encode('utf8'))
	open(configFile, 'wt').write(str(novels))
开发者ID:niu2x,项目名称:novelpush,代码行数:32,代码来源:a.py

示例4: prn_tbl_sec

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import encode [as 别名]
def prn_tbl_sec(index, node) :
	global node_id, curr_dep, last_dep, depth, opTyp
	if index != 0 :
		print >>sys.stderr,"...Start of PART, depth="+str(depth)
		ce = PyQuery(node)
    	# Print the part heading as containing node
		partLst = ce.prevAll('h3')
		partTxt = PyQuery(partLst[len(partLst)-1]).text()
		if index % 2 == 0 :
			print '<node CREATED="1347382439772" ID="PartID_'+str(index)+'" POSITION="left" MODIFIED="1347382510988" TEXT="'+partTxt.encode('utf-8')+'">'
		else :
			print '<node CREATED="1347382439772" ID="PartID_'+str(index)+'" POSITION="right" MODIFIED="1347382510988" TEXT="'+partTxt.encode('utf-8')+'">'
    	rows = ce('tr')
    	rows.each(prn_mm_for_sec)
    	# Print the closing tags for this table
    	print >>sys.stderr,"...End of PART, depth="+str(depth)
    	for i in range (0,depth) :
      		print '</node>'
    	print '</node>' #For the part heading containing node
    	depth=0
    	last_dep = 3
开发者ID:appanp,项目名称:ceqna,代码行数:23,代码来源:html_to_mm.py

示例5: prn_mm_for_sec

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import encode [as 别名]
def prn_mm_for_sec(index, node) :
  global last_rowTxt,node_id, curr_dep, last_dep, depth
  ce = PyQuery(node)
  rowTxt = ce.text()
  cols = ce('td')
  curr_dep = len(cols)

  # First close the previous node if required
  #if curr_dep == 1 and cols[0].text() == '' :
  if curr_dep == 1 :
       # This is a blank line which ends a section or sub-sec
       print >>sys.stderr,"...Blank line: End of NODE, depth="+str(depth)
       print >>sys.stderr,"......Last Row Text:"+last_rowTxt
       for i in range (0,depth) :
           print '</node>'
       depth=0
  elif curr_dep == (last_dep + 1) :
    # This means a new nesting starts, just inc. depth
    depth = depth + 1
    if index == 0 :
        print >>sys.stderr,"...Start of new level-2 node: "+rowTxt
  elif (curr_dep + 1) == last_dep :
    # This means a nesting has ended, dec. depth & print 2 end tags
    depth = depth - 1
    print '</node>'
    print '</node>'
  elif curr_dep  == last_dep :
    # This means are at the same level: just end the previous node tag
    print '</node>'
  elif curr_dep >= 3 and  last_dep == 1 :
    # This means start of a new level-1 node
    # DO NOTHING
    print >>sys.stderr,"...Start of new level-2 node: "+rowTxt
    depth = 1
  else :
    print >>sys.stderr,"...Curr dep. is neither one more nor less than prev. depth"
    print >>sys.stderr,"......Curr. dep:"+str(curr_dep)+" last dep:"+str(last_dep)
    print >>sys.stderr,"......Last Row Text:"+last_rowTxt
    print >>sys.stderr,"......Curr. Row Text:"+rowTxt
  # Next print the text for current node if not empty line
  if curr_dep >= 2 :
    nodeTxt = PyQuery(cols[curr_dep - 2]).text()+" "+PyQuery(cols[curr_dep - 1]).text()
    print '<node CREATED="1347382439772" ID="ID_'+str(node_id)+'" MODIFIED="1347382510988" TEXT="'+nodeTxt.encode('utf-8')+'">'
  last_dep = curr_dep
  last_rowTxt = rowTxt
  node_id = node_id + 1
开发者ID:appanp,项目名称:ceqna,代码行数:48,代码来源:html_to_mm.py


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