Using Python requests.get to parse html code that does not load at once

后端 未结 2 1558
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-21 05:48

I am trying to write a Python script that will periodically check a website to see if an item is available. I have used requests.get, lxml.html, and xpath successfully in

2条回答
  •  清酒与你
    2020-12-21 06:22

    The page uses javascript to load the table which is not loaded when requests gets the html so you are getting all the html just not what is generated using javascript, you could use selenium combined with phantomjs for headless browsing to get the html:

    from selenium import webdriver
    
    browser = webdriver.PhantomJS()
    browser.get("http://www.anthropologie.eu/anthro/index.jsp#/")
    html = browser.page_source
    print(html)
    

提交回复
热议问题