我正在运行一个 python 脚本。我收到一个无法解释的语法错误for
。这是代码:
today = datetime.date.today()
url="http://www.99acres.com/property-in-velachery-chennai-south-ffid?"
print "INSERT INTO Property (URL,Rooms, Place, Phonenumber1,Phonenumber2,Phonenumber3,Typeofperson, Name)"
print "VALUES ("
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'})
for eachproperty in properties:
print today,","+ "http:/" + eachproperty['href'] ",", eachproperty.string"," ,.join(re.findall("'([a-zA-Z0-9,\s]*)'", eachproperty['onclick']))
print ")"
错误是
$ python properties.py
File "properties.py", line 15
for eachproperty in properties:
^
SyntaxError: invalid syntax
更新
以下行正确吗?
properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'}))