标签:os ar for sp on html c line ad
# -*-coding:utf-8-*- import os import sys from bs4 import BeautifulSoup reload(sys) sys.setdefaultencoding("utf-8") fp = open(‘txt.txt‘,‘a‘) for i in range(3): path = sys.argv[1] s = path + str(i+1) +‘.html‘ html_doc = open(str(s)) soup = BeautifulSoup(html_doc) for tabb in soup.find_all(‘tr‘): print for tdd in tabb.find_all(‘td‘): # print tdd.get_text()+",", fp.writelines(tdd.get_text()+‘,‘) fp.writelines(‘\n‘) fp.close()
标签:os ar for sp on html c line ad
原文地址:http://my.oschina.net/frostz/blog/313101