报错could not be imported, invalid character,求解非常感谢!
# -*- coding: utf-8 -*- class HtmlOutputer(object): def __init__(self): self.datas = [] def collect_data(self, data): if data is None: return self.datas.append(data) def output_html(self): fout = open('output.html', 'w') fout.write('<html>') fout.write('<body>') fout.write('<table>') for data in self.datas: fout.write('<tr>') fout.write('<td>%s</td>'%data['url'].encode()) fout.write('<td>%s</td>'%data['title'].encode()) fout.write('<td>%s</td>'%data['summary'].encode()) fout.write('</tr>') fout.write('</table>') fout.write('</body>') fout.write('</html>') fout.close()
============================= ERRORS =============================
Traceback (most recent call last):
File "C:\Users\Administrator\.p2\pool\plugins\org.python.pydev.core_6.3.3.201805051638\pysrc\_pydev_runfiles\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "D:\practice\mooc\src\baike_spider\spider_main.py", line 23
if count == 1000:
  ^
SyntaxError: invalid character in identifier
ERROR: Module: spider_main could not be imported (file: D:/practice/mooc/src/baike_spider/spider_main.py).
# -*- coding: utf-8 -*- class HtmlOutputer(object): def __init__(self): self.datas = [] def collect_data(self, data): if data is None: return self.datas.append(data) def output_html(self): fout = open('output.html', 'w') fout.write('<html>') fout.write('<body>') fout.write('<table>') for data in self.datas: fout.write('<tr>') fout.write('<td>%s</td>'%data['url'].encode()) fout.write('<td>%s</td>'%data['title'].encode()) fout.write('<td>%s</td>'%data['summary'].encode()) fout.write('</tr>') fout.write('</table>') fout.write('</body>') fout.write('</html>') fout.close()
============================= ERRORS =============================
Traceback (most recent call last):
File "C:\Users\Administrator\.p2\pool\plugins\org.python.pydev.core_6.3.3.201805051638\pysrc\_pydev_runfiles\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "D:\practice\mooc\src\baike_spider\html_parser.py", line 25
title_node = soup.find('dd', class="lemmaWgt-lemmaTitle-title").find('h1')
^
SyntaxError: invalid syntax
ERROR: Module: html_parser could not be imported (file: D:/practice/mooc/src/baike_spider/html_parser.py).
# -*- coding: utf-8 -*- class HtmlOutputer(object): def __init__(self): self.datas = [] def collect_data(self, data): if data is None: return self.datas.append(data) def output_html(self): fout = open('output.html', 'w') fout.write('<html>') fout.write('<body>') fout.write('<table>') for data in self.datas: fout.write('<tr>') fout.write('<td>%s</td>'%data['url'].encode()) fout.write('<td>%s</td>'%data['title'].encode()) fout.write('<td>%s</td>'%data['summary'].encode()) fout.write('</tr>') fout.write('</table>') fout.write('</body>') fout.write('</html>') fout.close()
============================= ERRORS =============================
Traceback (most recent call last):
File "C:\Users\Administrator\.p2\pool\plugins\org.python.pydev.core_6.3.3.201805051638\pysrc\_pydev_runfiles\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "D:\practice\mooc\src\baike_spider\html_outputer.py", line 8
if data == None:
^
SyntaxError: invalid character in identifier
ERROR: Module: html_outputer could not be imported (file: D:/practice/mooc/src/baike_spider/html_outputer.py).