"""
获取到每一页的请求地址
f12->网络->全部->
https://97.push2.eastmoney.com/api/qt/clist/get?pn=1&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048
pn: pagenum 页码
fs 必填参数,每次请求都一样
"""
# 1. 分析数据所在请求地址与请求参数
# 2. 导入模块
# from urllib import request
# import json
#
# # 6. 打开文件 写入信息
# with open("公司信息.txt", "w") as f:
# # 5. 获取指定页码中的所有公司
# for i in range(1, 11):
# print(f"当前正在采集第{i}页公司信息")
# # 3. 发起请求 获取数据
# res = request.urlopen(f"https://97.push2.eastmoney.com/api/qt/clist/get?pn={i}&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&dect=1&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1725257972755")
# content = res.read().decode()
# # 4. 解析数据 提取 股票信息
# datas = json.loads(content)
# for data in datas['data']['diff']:
# # 7. 解析指定字段
# f.write(f"{data['f14']}, {data['f15']}, {data['f16']} \n")
# 字典中的三个属性 每个属性之间使用逗号隔开, 属性键与值之间使用冒号隔开
# student = {
# "id": 1001,
# "name": "马云",
# "address": "杭州"
# }
# print(student["f3"])
# company = {
# "f1": 2,
# "f2": 2.09,
# "f3": 10.0,
# "f4": 0.19,
# "f5": 1450545,
# "f6": 296406971.6,
# "f7": 8.95,
# "f8": 3.19,
# "f9": -14.14,
# "f10": 6.09,
# "f11": 0.0,
# "f12": "000627",
# "f13": 0,
# "f14": "天茂集团",
# "f15": 2.09,
# "f16": 1.92,
# "f17": 1.96,
# "f18": 1.9,
# "f20": 10325914955,
# "f21": 9514733705,
# "f22": 0.0,
# "f23": 0.5,
# "f24": 6.09,
# "f25": -26.41,
# "f62": 48229449.0,
# "f115": -12.45,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }
#
# print(company["f14"], company["f12"], company["f13"], )
# 列表中存储字母
# datas = ["A", "B", "C", "D", "E", "F"]
#
# for data in datas:
# print(data)
datas = [
{"id": 101, "name": "马云", "age": 18},
{"id": 102, "name": "马化腾", "age": 20},
{"id": 103, "name": "马加爵", "age": 25}
]
for data in datas:
print(data['name'])
# datas = [
# {
# "f1": 2,
# "f2": 18.04,
# "f3": 10.0,
# "f4": 1.64,
# "f5": 315463,
# "f6": 560407540.0,
# "f7": 9.63,
# "f8": 6.74,
# "f9": 49.55,
# "f10": 5.32,
# "f11": 0.0,
# "f12": "600645",
# "f13": 1,
# "f14": "中源协和",
# "f15": 18.04,
# "f16": 16.46,
# "f17": 16.5,
# "f18": 16.4,
# "f20": 8441797976,
# "f21": 8438573777,
# "f22": 0.0,
# "f23": 2.34,
# "f24": 7.89,
# "f25": -11.0,
# "f62": 113623798.0,
# "f115": 77.47,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 7.37,
# "f3": 10.0,
# "f4": 0.67,
# "f5": 80644,
# "f6": 58954858.31,
# "f7": 5.22,
# "f8": 1.78,
# "f9": 12.48,
# "f10": 3.34,
# "f11": 0.0,
# "f12": "002950",
# "f13": 0,
# "f14": "奥美医疗",
# "f15": 7.37,
# "f16": 7.02,
# "f17": 7.2,
# "f18": 6.7,
# "f20": 4667166050,
# "f21": 3331204690,
# "f22": 0.0,
# "f23": 1.43,
# "f24": -1.47,
# "f25": -22.01,
# "f62": 28908566.0,
# "f115": 33.25,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 2.09,
# "f3": 10.0,
# "f4": 0.19,
# "f5": 1450545,
# "f6": 296406971.6,
# "f7": 8.95,
# "f8": 3.19,
# "f9": -14.14,
# "f10": 6.09,
# "f11": 0.0,
# "f12": "000627",
# "f13": 0,
# "f14": "天茂集团",
# "f15": 2.09,
# "f16": 1.92,
# "f17": 1.96,
# "f18": 1.9,
# "f20": 10325914955,
# "f21": 9514733705,
# "f22": 0.0,
# "f23": 0.5,
# "f24": 6.09,
# "f25": -26.41,
# "f62": 48229449.0,
# "f115": -12.45,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 28.38,
# "f3": 10.0,
# "f4": 2.58,
# "f5": 1161065,
# "f6": 3261187898.25,
# "f7": 4.65,
# "f8": 11.12,
# "f9": 84.06,
# "f10": 1.07,
# "f11": 0.0,
# "f12": "000062",
# "f13": 0,
# "f14": "深圳华强",
# "f15": 28.38,
# "f16": 27.18,
# "f17": 28.0,
# "f18": 25.8,
# "f20": 29682906558,
# "f21": 29640649987,
# "f22": 0.0,
# "f23": 4.16,
# "f24": 218.16,
# "f25": 156.37,
# "f62": -504678016.0,
# "f115": 78.7,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 10.57,
# "f3": 9.99,
# "f4": 0.96,
# "f5": 45269,
# "f6": 47849333.0,
# "f7": 0.0,
# "f8": 1.97,
# "f9": 24.35,
# "f10": 1.33,
# "f11": 0.0,
# "f12": "603787",
# "f13": 1,
# "f14": "新日股份",
# "f15": 10.57,
# "f16": 10.57,
# "f17": 10.57,
# "f18": 9.61,
# "f20": 2432619860,
# "f21": 2432619860,
# "f22": 0.0,
# "f23": 1.56,
# "f24": 0.86,
# "f25": -14.48,
# "f62": 12583585.0,
# "f115": 26.68,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 9.03,
# "f3": 9.99,
# "f4": 0.82,
# "f5": 49315,
# "f6": 44531337.0,
# "f7": 0.0,
# "f8": 0.89,
# "f9": -15.59,
# "f10": 0.11,
# "f11": 0.0,
# "f12": "603626",
# "f13": 1,
# "f14": "科森科技",
# "f15": 9.03,
# "f16": 9.03,
# "f17": 9.03,
# "f18": 8.21,
# "f20": 5010563601,
# "f21": 5010563601,
# "f22": 0.0,
# "f23": 1.95,
# "f24": 67.84,
# "f25": 0.78,
# "f62": 24138146.0,
# "f115": -13.44,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 8.81,
# "f3": 9.99,
# "f4": 0.8,
# "f5": 174787,
# "f6": 151219031.0,
# "f7": 10.99,
# "f8": 10.58,
# "f9": -32.51,
# "f10": 5.2,
# "f11": 0.0,
# "f12": "603810",
# "f13": 1,
# "f14": "丰山集团",
# "f15": 8.81,
# "f16": 7.93,
# "f17": 8.02,
# "f18": 8.01,
# "f20": 1455804433,
# "f21": 1455804433,
# "f22": 0.0,
# "f23": 0.99,
# "f24": 0.0,
# "f25": -34.11,
# "f62": 30654616.0,
# "f115": -18.45,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 11.13,
# "f3": 9.98,
# "f4": 1.01,
# "f5": 351483,
# "f6": 383068493.33,
# "f7": 8.3,
# "f8": 23.16,
# "f9": 452.96,
# "f10": 3.51,
# "f11": 0.0,
# "f12": "002806",
# "f13": 0,
# "f14": "华锋股份",
# "f15": 11.13,
# "f16": 10.29,
# "f17": 10.39,
# "f18": 10.12,
# "f20": 2116424627,
# "f21": 1689329197,
# "f22": 0.0,
# "f23": 2.54,
# "f24": 48.01,
# "f25": -18.64,
# "f62": 40331405.0,
# "f115": -7.22,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 5.29,
# "f3": 9.98,
# "f4": 0.48,
# "f5": 630815,
# "f6": 328041130.3,
# "f7": 6.03,
# "f8": 11.39,
# "f9": -17.97,
# "f10": 4.13,
# "f11": 0.0,
# "f12": "002514",
# "f13": 0,
# "f14": "宝馨科技",
# "f15": 5.29,
# "f16": 5.0,
# "f17": 5.2,
# "f18": 4.81,
# "f20": 3808981257,
# "f21": 2930841257,
# "f22": 0.0,
# "f23": 4.52,
# "f24": 16.52,
# "f25": -39.75,
# "f62": -7493496.0,
# "f115": -12.53,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 5.18,
# "f3": 9.98,
# "f4": 0.47,
# "f5": 267564,
# "f6": 132986349.12,
# "f7": 10.83,
# "f8": 7.96,
# "f9": 168.3,
# "f10": 2.41,
# "f11": 0.0,
# "f12": "002691",
# "f13": 0,
# "f14": "冀凯股份",
# "f15": 5.18,
# "f16": 4.67,
# "f17": 4.72,
# "f18": 4.71,
# "f20": 1761200000,
# "f21": 1740377980,
# "f22": 0.0,
# "f23": 1.96,
# "f24": 13.1,
# "f25": -30.84,
# "f62": 14481257.0,
# "f115": 82.73,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 18.52,
# "f3": 9.98,
# "f4": 1.68,
# "f5": 97557,
# "f6": 176055728.0,
# "f7": 9.74,
# "f8": 4.58,
# "f9": 102.05,
# "f10": 1.5,
# "f11": 0.0,
# "f12": "605218",
# "f13": 1,
# "f14": "伟时电子",
# "f15": 18.52,
# "f16": 16.88,
# "f17": 16.9,
# "f18": 16.84,
# "f20": 3941675679,
# "f21": 3941675679,
# "f22": 0.0,
# "f23": 3.12,
# "f24": 12.24,
# "f25": -28.85,
# "f62": 80758311.0,
# "f115": 39.1,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 18.3,
# "f3": 9.98,
# "f4": 1.66,
# "f5": 191102,
# "f6": 346624160.0,
# "f7": 4.69,
# "f8": 32.46,
# "f9": 30.07,
# "f10": 7.78,
# "f11": 0.0,
# "f12": "603004",
# "f13": 1,
# "f14": "鼎龙科技",
# "f15": 18.3,
# "f16": 17.52,
# "f17": 18.3,
# "f18": 16.64,
# "f20": 4310016000,
# "f21": 1077504000,
# "f22": 0.0,
# "f23": 2.27,
# "f24": 0.99,
# "f25": -48.85,
# "f62": 62591631.0,
# "f115": 27.24,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 8.27,
# "f3": 9.97,
# "f4": 0.75,
# "f5": 103835,
# "f6": 83135183.0,
# "f7": 12.63,
# "f8": 4.4,
# "f9": -35.66,
# "f10": 1.26,
# "f11": 0.0,
# "f12": "603196",
# "f13": 1,
# "f14": "日播时尚",
# "f15": 8.27,
# "f16": 7.32,
# "f17": 7.35,
# "f18": 7.52,
# "f20": 1960017390,
# "f21": 1953219450,
# "f22": 0.0,
# "f23": 2.56,
# "f24": 6.3,
# "f25": -38.7,
# "f62": 26281451.0,
# "f115": -125.22,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 3.42,
# "f3": 9.97,
# "f4": 0.31,
# "f5": 251168,
# "f6": 83339106.0,
# "f7": 10.29,
# "f8": 5.72,
# "f9": -54.24,
# "f10": 3.03,
# "f11": 0.0,
# "f12": "600243",
# "f13": 1,
# "f14": "青海华鼎",
# "f15": 3.42,
# "f16": 3.1,
# "f17": 3.1,
# "f18": 3.11,
# "f20": 1500867000,
# "f21": 1500867000,
# "f22": 0.0,
# "f23": 2.1,
# "f24": 22.58,
# "f25": -28.3,
# "f62": 25805756.0,
# "f115": -9.81,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 2.65,
# "f3": 9.96,
# "f4": 0.24,
# "f5": 166651,
# "f6": 42795472.0,
# "f7": 11.62,
# "f8": 5.79,
# "f9": -74.69,
# "f10": 1.16,
# "f11": 0.0,
# "f12": "000820",
# "f13": 0,
# "f14": "神雾节能",
# "f15": 2.65,
# "f16": 2.37,
# "f17": 2.41,
# "f18": 2.41,
# "f20": 1688699838,
# "f21": 762290838,
# "f22": 0.0,
# "f23": 22.15,
# "f24": 15.72,
# "f25": -32.57,
# "f62": 19880954.0,
# "f115": -129.01,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 3.87,
# "f3": 9.94,
# "f4": 0.35,
# "f5": 454250,
# "f6": 175109375.55,
# "f7": 3.98,
# "f8": 5.07,
# "f9": -41.5,
# "f10": 5.23,
# "f11": 0.0,
# "f12": "000859",
# "f13": 0,
# "f14": "国风新材",
# "f15": 3.87,
# "f16": 3.73,
# "f17": 3.87,
# "f18": 3.52,
# "f20": 3467428169,
# "f21": 3466955061,
# "f22": 0.0,
# "f23": 1.23,
# "f24": 12.5,
# "f25": -27.12,
# "f62": 8613529.0,
# "f115": -48.39,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 4.88,
# "f3": 9.91,
# "f4": 0.44,
# "f5": 81469,
# "f6": 39756721.0,
# "f7": 0.0,
# "f8": 0.44,
# "f9": 197.2,
# "f10": 0.69,
# "f11": 0.0,
# "f12": "600550",
# "f13": 1,
# "f14": "保变电气",
# "f15": 4.88,
# "f16": 4.88,
# "f17": 4.88,
# "f18": 4.44,
# "f20": 8986658982,
# "f21": 8986658982,
# "f22": 0.0,
# "f23": 17.0,
# "f24": 7.73,
# "f25": 0.0,
# "f62": 21148509.0,
# "f115": -62.64,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 1.13,
# "f3": 9.71,
# "f4": 0.1,
# "f5": 3054747,
# "f6": 335932157.75,
# "f7": 10.68,
# "f8": 20.84,
# "f9": -3.67,
# "f10": 2.2,
# "f11": 0.0,
# "f12": "002717",
# "f13": 0,
# "f14": "岭南股份",
# "f15": 1.13,
# "f16": 1.02,
# "f17": 1.02,
# "f18": 1.03,
# "f20": 1904230075,
# "f21": 1656251063,
# "f22": 0.0,
# "f23": 0.99,
# "f24": 5.61,
# "f25": -65.02,
# "f62": 45076527.0,
# "f115": -1.53,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 8.3,
# "f3": 9.35,
# "f4": 0.71,
# "f5": 45976,
# "f6": 37856404.33,
# "f7": 16.47,
# "f8": 10.31,
# "f9": 29.08,
# "f10": 5.58,
# "f11": 0.0,
# "f12": "430685",
# "f13": 0,
# "f14": "新芝生物",
# "f15": 8.69,
# "f16": 7.44,
# "f17": 7.44,
# "f18": 7.59,
# "f20": 759582310,
# "f21": 370050860,
# "f22": -0.48,
# "f23": 1.49,
# "f24": 8.36,
# "f25": -38.56,
# "f62": 4622747.0,
# "f115": 17.72,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }, {
# "f1": 2,
# "f2": 20.59,
# "f3": 9.35,
# "f4": 1.76,
# "f5": 84646,
# "f6": 173573343.14,
# "f7": 16.57,
# "f8": 8.98,
# "f9": -50.0,
# "f10": 2.58,
# "f11": -0.05,
# "f12": "301049",
# "f13": 0,
# "f14": "超越科技",
# "f15": 22.18,
# "f16": 19.06,
# "f17": 19.37,
# "f18": 18.83,
# "f20": 1940676147,
# "f21": 1940676147,
# "f22": 0.0,
# "f23": 2.65,
# "f24": 9.23,
# "f25": -11.1,
# "f62": 5492985.0,
# "f115": -18.13,
# "f128": "-",
# "f140": "-",
# "f141": "-",
# "f136": "-",
# "f152": 2
# }]
#
# for data in datas:
# print(data['f12'], data['f14'])