作家
登录

如何用Python解析HTML?

作者: 来源: 2018-03-28 00:03:06 阅读 我要评论

import os
  •  
  • imagelist = []
  • for line in open('/tmp/imagelist_parse4.txt').xreadlines():
  • imagelist.append(line)
  •  
  • imagelist.sort()
  •  
  • outfile = open('/tmp/imagelist_parse4_sorted.txt', 'w')
  • outfile.writelines(imagelist)
  • outfile.close()
  • 这会攫取文件内容,并存储为列表,对其排序,然后另存为另一个文件。 之后,我可以做到以下几点:

    1. ls /home/gregp/development/Scribus15x/doc/en/images/*.png > '/tmp/actual_images.txt'
    1. index = 3
    2. while index < linelength:
    3. if (all_text[index] == '='):
    4. if (all_text[index-3] == 's') and (all_text[index-2] == 'r') and (all_text[index-1] == 'c'):
    5. imagefound(all_text, imagelist,

        推荐阅读

        苹果秘密专利曝光:一支能在空中写字的Apple Pen

      沙龙晃荡 | 3月31日 京东、微博、华为拭魅战专家与你合营商量容器技巧实践! 2015年,固执的苹不雅也推出了带压力感应的手写笔,然则迄今为止,这个笔如今只能在iPad Pro上应用,这让苹不雅>>>详细阅读


      本文标题:如何用Python解析HTML?

      地址:http://www.17bianji.com/lsqh/40963.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)