擅长:python、mysql、java
<p>JavaScript函数<code>downloadCSV</code>是<code>gijgo.min.js</code>的一部分。它调用<code>getCSV</code>,该函数遍历表中的字段并动态生成CSV文件</p>
<p>幸运的是,您不必处理CSV或从页面中删除任何内容。要获取所需数据,只需向浏览器在访问页面时请求的RESTful API发出HTTP get请求:</p>
<pre><code>def main():
import requests
url = "https://www.nseindia.com/api/live-analysis-oi-spurts-underlyings"
headers = {
"user-agent": "Mozilla/5.0"
}
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()["data"]
print(f"There are {len(data)} items in total.")
print(f"The first item is:\n{data[0]}")
return 0
if __name__ == "__main__":
import sys
sys.exit(main())
</code></pre>
<p>输出:</p>
<pre><code>There are 143 items in total.
The first item is:
{'symbol': 'MOTHERSUMI', 'latestOI': 7182, 'prevOI': 4674, 'changeInOI': 2508, 'avgInOI': 53.66, 'volume': 12519, 'futValue': 53892.6066, 'optValue': 3788085280, 'total': 55585.0344, 'premValue': 1692.4278, 'underlyingValue': 104}
>>>
</code></pre>