1

I am running a python script. I am getting an unexplained syntax error in for line. This is the code:

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 ")"

Error is

$ python properties.py
  File "properties.py", line 15
    for eachproperty in properties:
                                  ^
SyntaxError: invalid syntax

Update

Is the following line correct ?

properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'}))
2
  • 3
    Count the number of ) and ( on the previous line. Commented Sep 5, 2013 at 10:08
  • @AshwiniChaudhary I have updated the question with one more doubt. Because, there is no error displayed. but no output too Commented Sep 5, 2013 at 10:25

1 Answer 1

1

The preceding line has an incorrect count of opening ( parenthesis compared to the number of closing parens:

properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'})
#                      --^^                     ---^      ---^-^-^                -----^

Add one more closing ):

properties = soup.findAll(('a', {'title':re.compile('Bedroom')}),('i',{'class':'pdate'}))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.