javascriptpythonweb-scrapingbeautifulsoup

Web scraping with Python, but values are empty


I'd like to grab values from this site: http://cdn.ime-co.ir/ with BeautifulSoup , but values are empty when I try to import tables. I think disabled with javascrip or anything that I don't know. Please help me to export values to csv or txt format.

import urllib2
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://cdn.ime-co.ir/').read())
print soup

Solution

  • BeautifulSoup doesn't support Javascript. If you just need to parse it once you can obviously save the source to a file and parse from there. If you need to grab the site more than once you could look at using Webkit (here's an example using PyQT4 with Webkit) or PhantomJS to generate source that you can parse in Python.