def phantomjs_retrieve ( url , data = None ) : range_limit ( ) print "pGET" , url process = subprocess . Popen ( [ 'phantomjs' , PHANTOM_SCRIPT , url ] , stdout = subprocess . PIPE ) out = process . communicate ( ) process . wait ( ) response = out [ 0 ] . decode ( 'utf-8' , 'ignore' ) status = response [ : 2 ] body = response [ 3 : ] # After the 'ok ' part. if status == 'ok' : return 200 , body else : return 404 , body
how to get data using phantomjs and python
Retrieve the given URL using PhantomJS . PhantomJS will evaluate all scripts and return the HTML after body . onload . url - The page URL to retrieve data - The form data . TODO : Currently ignored .
def phantomjs_retrieve(url, data=None):
    """Retrieve the given URL using PhantomJS.
    PhantomJS will evaluate all scripts and return the HTML after body.onload.
    
    url  - The page URL to retrieve
    data - The form data. TODO: Currently ignored.

    Returns a status code (e.g. 200) and the HTML as a unicode string.
    """
    range_limit()
    print "pGET", url
    process = subprocess.Popen(['phantomjs', PHANTOM_SCRIPT, url], stdout=subprocess.PIPE)
    out = process.communicate()
    process.wait()
    response = out[0].decode('utf-8', 'ignore')
    status = response[:2]
    body = response[3:] # After the 'ok ' part.
    if status == 'ok':
        return 200, body
    else:
        return 404, body