France

All articles by France

 

Xpath 多级解析

selector = Selector(response) divs = selector.xpath(‘//div[@class=”detials-title-cont”]’) for div in divs: h4divs = div.xpath(“./h4/text()”) for h4div in h4divs: print “——- “,h4div.extract() uldivs = div.xpath(‘./following-sibling::ul[1]’) for uldiv in uldivs: uladivs = uldiv.xpath(“./li/div/div/a/text()”) for uladiv in uladivs: print “parse_tpo_lecture_select txt ——————” ,uladiv.extract()
Continue reading...  

Python 正则 处理网页

# -*- coding: utf-8-*- import re ##过滤HTML中的标签 #将HTML中标签等信息去掉 #@param htmlstr HTML字符串. def filter_tags(htmlstr): #先过滤CDATA re_cdata=re.compile(‘//< !\[CDATA\[[^>]*//\]\]>’,re.I) #匹配CDATA re_script=re.compile(‘< \s*script[^>]*>[^< ]*‘,re.I)#Script re_style=re.compile(‘< \s*style[^>]*>[^< ]*‘,re.I)#style re_br=re.compile(‘‘)#处理换行 re_h=re.compile(‘]*>’)#HTML标签 re_comment=re.compile(‘‘)#HTML注释 s=re_cdata.sub(”,htmlstr)#去掉CDATA s=re_script.sub(”,s) #去掉SCRIPT s=re_style.sub(”,s)#去掉style s=re_br.sub(‘\n’,s)#将br转换为换行 s=re_h.sub(”,s) #去掉HTML 标签 s=re_comment.sub(”,s)#去掉HTML注释 #去掉多余的空行 blank_line=re.compile(‘\n+’) s=blank_line.sub(‘\n’,s) s=replaceCharEntity(s)#替换实体 return s ##替换常用HTML字符实体. #使用正常的字符替换HTML中特殊的字符实体. #你可以添加新的实体字符到CHAR_ENTITIES中,处理更多HTML字符实体. #@param htmlstr HTML字符串. def replaceCharEntity(htmlstr): CHAR_ENTITIES={‘nbsp’:’ ‘,’160′:’ ‘, ‘lt’:’< ','60':'‘,’62’:’>’, ‘amp’:’&’,’38’:’&’,
Continue reading...  

Super Linux server

1、开机启动项配置: root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# update-rc.d -f apache2 remove Removing any system startup links for /etc/init.d/apache2 … /etc/rc0.d/K09apache2 /etc/rc1.d/K09apache2 /etc/rc2.d/S91apache2 /etc/rc3.d/S91apache2 /etc/rc4.d/S91apache2 /etc/rc5.d/S91apache2 /etc/rc6.d/K09apache2 root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# update-rc.d -f apache2 defaults Adding system startup for /etc/init.d/apache2 … /etc/rc0.d/K20apache2 -> ../init.d/apache2 /etc/rc1.d/K20apache2 -> ../init.d/apache2 /etc/rc6.d/K20apache2 -> ../init.d/apache2 /etc/rc2.d/S20apache2 -> ../init.d/apache2 /etc/rc3.d/S20apache2 -> ../init.d/apache2 /etc/rc4.d/S20apache2 -> ../init.d/apache2 /etc/rc5.d/S20apache2 -> ../init.d/apache2 root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# ls
Continue reading...  

Audio Post

This is dummy copy. It is not meant to be read. It has been placed here solely to demonstrate the look and feel of finished, typeset text. Only for show. He who searches for meaning here will be sorely disappointed. These words are here to provide the reader with a basic impression of how actual
Continue reading...  

This is a video post and it is very nice

Meaningless mock-up, mock turtle soup spilled on a mock turtle neck. Mach I Convertible copy. To kill a mockingbird, you need only force it to read this copy. This is Meaningless filler. (Elvis movies.) It is not meant to be a forum for value judgments nor a scholarly diatribe on how virtue should be measured.
Continue reading...