Get values from onclick attribute using python bs4
I am unable to parse through the onclick attribute to get only selected
values. Here is the onclick attribute
onclick="try{appendPropertyPosition(this,'B10331465','9941951739','','Dealer','Murugan.N');jsb9onUnloadTracking();jsevt.stopBubble(event);}catch(e){};"
How do I get only selected values from this onclick attribute such as
(phonenumber , '', 'Dealer','Name'). Here is my code.
from bs4 import BeautifulSoup
import urllib2
import re
url="http://www.99acres.com/property-in-velachery-chennai-south-ffid?"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
properties = soup.findAll('a', title=re.compile('Bedroom'))
for eachproperty in properties:
print "http:/"+ eachproperty['href']+",", eachproperty.string,
eachproperty['onclick']
Hope my question is clear.
No comments:
Post a Comment