我正在尝试打印 nba 选秀中的前 30 个选秀权。我正在使用页面: http: //nbadraft.net/2012mock_draft获取信息。当它运行时它说:
invalid syntax: python1.py, line 8, pos 28
File "/Users/seanyeh/Downloads/python1.py", line 8, in ?
patFinderLink = re.compile(‘<link rel.*href=”(.*)” />’)
所以这是我的代码:
import urllib2
from BeautifulSoup import BeautifulSoup
# or if your're using BeautifulSoup4:
# from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://nbadraft.net/2012mock_draft').read())
patFinderLink = re.compile(‘<link rel.*href=”(.*)” />’)
findPatLink = re.findall(patFinderLink,webpage)
listIterator = []
listIterator[:] = range(1,30)
for i in listIterator:
print findPatLink[i]