所以使用Python 2.7,现在从3.3.4无效的语法字符串比较蟒蛇维基解析器
恢复回后,我使用
import sys
import urllib
import urllib2
from bs4 import BeautifulSoup
article = sys.argv[1]
articleURL = urllib.quote(article)
print article
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
MAX_HOPS = 100
count=1
While article!="Philosophy" and count<MAX_HOPS:
resource = opener.open("http://en.wikipedia.org/wiki/" + articleURL)
data = resource.read()
resource.close()
soup = BeautifulSoup(data)
print soup.find('div',id="bodyContent").p
count+=1
的同时文章!=“哲学”我得到一个无效语法指向文章的错误。任何想法我做错了
'while'!='while'。后者是一个Python循环命令。前者是未定义的,因此语法错误... – ig0774