1

My code looks like this.

from bs4 import BeautifulSoup
import requests

r  = requests.get("http://www.data.com.sg/iCurrentLaunch.jsp")
data = r.text
soup = BeautifulSoup(data)
n = soup.findAll('table')[7].findAll('table')
for tab in n:
    print tab.findAll('td')[1].text

what I am getting is the property name till IDYLLIC SUITES,after that I get error "list index out of range".What is the problem?

sameedhayat
  • 61
  • 1
  • 8

1 Answers1

2

I am not sure what is exactly bothering you. Because when I tried your code (as it is) it worked for me.

Still, try changing the parser, may be to html5lib

So do,

pip install html5lib

And then change your code to,

from bs4 import BeautifulSoup
import requests

r  = requests.get("http://www.data.com.sg/iCurrentLaunch.jsp")
data = r.text
soup = BeautifulSoup(data,'html5lib') # Change of Parser
n = soup.findAll('table')[7].findAll('table')
for tab in n:
    print tab.findAll('td')[1].text

Let me know if it helps

Md. Mohsin
  • 1,822
  • 3
  • 19
  • 34