Requests won't get the text from web page?

前端 未结 2 495
抹茶落季
抹茶落季 2021-01-23 14:55

I am trying to get the value of VIX from a webpage.

The code I am using:

raw_page = requests.get(\"https://www.nseindia.com/live_market/dynaContent/live         


        
2条回答
  •  猫巷女王i
    2021-01-23 15:35

    When you open the page in a web browser, the text (e.g., 15.785) is inserted into the span element by the getIndiaVixData.js script.

    When you get the page using requests in Python, only the HTML code is retrieved and no JavaScript processing is done. So, the span element stays empty.

    It is impossible to get that data by solely parsing the HTML code of the page using requests.

提交回复
热议问题