LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

How to get html with javascript rendered sourcecode by using selenium

I run a query in one web page, then I get result url. If I right click see html source, I can see the html code generated by JS. If I simply use urllib, python cannot get the JS code. So I see some solution using selenium. Here's my code:

from selenium import webdriver
url = ''
driver = webdriver.PhantomJS(executable_path='C:\python27\scripts\phantomjs.exe')
print driver.page_source

>>> <html><head></head><body></body></html>         Obviously It's not right!!

Here's the source code I need in right click windows, (I want the INFORMATION part)

</script></div><div class="searchColRight"><div id="topActions" class="clearfix 
noPrint"><div id="breadcrumbs" class="left"><a title="Results Summary"
href="Default.aspx?    _act=VitalSearchR ...... <<INFORMATION I NEED>> ... 
to view the entire record.</p></div><script xmlns:msxsl="urn:schemas-microsoft-com:xslt">

        jQuery(document).ready(function() {
href: "#AncestryInformationTooltip", orientation: "bottomleft"});

So my question is How to get the information generated by JS?

Up Vote Down Vote 0 Votes
Posted 29 days ago


0 Answers
29 days ago