import urllib2
url = "http://www.bdfutbol.com/es/t/t2012-13.html"
request = urllib2.Request(url)
handle = urllib2.urlopen(request)
content = handle.read()
splitted_page = content.split('<div class="divclassificacio">', 1);
splitted_page = splitted_page[1].split("</div>", 1);
print "Downloads: " + splitted_page[0]所以我写了这段代码,用python从一个足球网站上检索数据,格式是html。我在将结果写到一个文件中,以及在python中显示表格时遇到了问题,这就是代码的作用。
另外,我想知道是否有人知道如何将表或数据转移到MySql表中?
发布于 2013-07-25 13:26:47
要写入文件,您可以使用以下命令:
with open('downloads.txt', 'w') as output_file:
output_file.write(splitted_page[0])为了转换到MySQL (或任何其他数据库),您必须首先在模式中对数据建模,然后通过python接口与其交互。This系列文章为如何在python中与数据库交互提供了很好的帮助。
https://stackoverflow.com/questions/17849626
复制相似问题