Python数据刮取
Pyton中的数据刮取。 代码运行良好,但它显示了我在下面提到的错误。 原因可能是什么Python数据刮取,python,excel,Python,Excel,Pyton中的数据刮取。 代码运行良好,但它显示了我在下面提到的错误。 原因可能是什么 import urllib2 from bs4 import BeautifulSoup from xlwt import workbook wb = Workbook() sheet1 = wb.add_sheet('Sheet1') soup = BeautifulSoup(urllib2.urlopen("http://en.wikipedia.org/wiki/List_of_Indian_
import urllib2
from bs4 import BeautifulSoup
from xlwt import workbook
wb = Workbook()
sheet1 = wb.add_sheet('Sheet1')
soup = BeautifulSoup(urllib2.urlopen("http://en.wikipedia.org/wiki/List_of_Indian_satellites").read())
for row in soup('table', {'class': 'wikitable sortable jquery-tablesorter’})[0].tbody('tr'):
tds = row('td')
sheet1.write(row, 0, tds[0].string)
sheet2.write(row, 1, tds[1].string)
wb.save('Performance Project.xls')
错误:文件“ProcessingProject.py”,第12行
SyntaxError:第12行文件ProcessingProject.py中的非ASCII字符“\xe2”
但未声明编码;有关详细信息,请参阅
#!/usr/bin/env python
# -*- coding: utf-8 -*-
将此添加到您的文件顶部中的行('table',{'class':'wikitable sortable jquery tablesorter'})[0]。tbody('tr'):
在jquery tablesorter之后使用了错误的字符作为单引号分隔符符号