python中for行的语法错误
我正在运行python脚本。我在python中for行的语法错误,python,beautifulsoup,screen-scraping,Python,Beautifulsoup,Screen Scraping,我正在运行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)"
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'}))
前一行的开始(
括号与结束括号的数量相比不正确:
properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'})
# --^^ ---^ ---^-^-^ -----^
再添加一个结账)
:
前一行的开始(
括号与结束括号的数量相比不正确:
properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'})
# --^^ ---^ ---^-^-^ -----^
再添加一个结账)
:
计算
)
和(
在前一行。@AshwiniChaudhary我用一个疑问更新了问题。因为,没有显示错误。但是没有输出来计算)
和(
在前一行。@AshwiniChaudhary我用一个疑问更新了问题。因为,没有显示错误。但是也没有输出