天天基金网高收益基金列表数据保存到Excle中#python爬虫小试牛刀之openpyxl

发布时间:2021-04-01 发表于话题:003096基金净值天天基金网 点击:15 当前位置:财神股票资讯网 > 健康养生 > 天天基金网高收益基金列表数据保存到Excle中#python爬虫小试牛刀之openpyxl 手机阅读

天天基金网高收益基金列表数据保存到Excle中#python爬虫小试牛刀之openpyxl

你好! 学习了openpyxl后,于是迫不及待的想练习一下,于是挑选了具有一定挑战性的天天基金网来进行爬取数据并保存练手,当然自己也搜索了其他人关于天天基金数据爬取的过程,但基本上都无法看懂,可能是我入行不深,这里我介绍一种小白都能看懂的方法,仅供大家参考学习。

1.最终得到的Excel表格:

我喜欢先将结果,将爬取的的数据采用openpyxl模块保存后的结果如下:
由于列表数据比较多,这里只截屏了一部分,大家可以去天天基金网上看看,其大致排布和这个是一样的。好了废话不多说,下面介绍一下爬取保存过程。

2.爬取+保存:

从标题我们不难看出,我们得到上面的结果 其实分两大步走,第一步是爬取,第二部就是保存了。保存的过程其实比较简单,仅仅涉及到一些基本的语句如:sheet.append(header)
sheet.append(rows),这里面的header和rows和我们的爬虫部分息息相关,所以这里就重点讲一下爬虫部分。

很多爬友都能进入到这个界面,就相当于你已经找到了爬取对的内容,但是对于内容的处理,很多人都讲得不够清楚,无法从根本上 提升我们的认知和知识。我们拷贝一部分出来重点分析一下。

过程分析:

这里先暂存一下数据:

var rankData = {datas:["002939|广发创新升级混合|混合型|2020-06-23|2.6236|1.78|6.39|12.69|29.36|45.26|121.64|145.97|148.08|42.17|173.69|3|1|1|0.15|0||211|1|1|10元|1.50%|0.15%|0.15%|1","519674|银河创新成长混合|混合型|2020-06-23|5.8228|0.94|9.08|9.97|26.17|46.08|121.46|139.04|147.14|44.53|482.28|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","005911|广发双擎升级混合A|混合型|2020-06-23|2.8574|1.95|7.00|12.83|27.51|39.95|121.34|||37.66|199.96|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","257070|国联安优选行业混合|混合型|2020-06-23|2.9781|2.75|8.72|12.24|31.08|54.21|118.03|131.61|95.03|51.10|266.94|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","161903|万家行业优选混合(LOF)|混合型|2020-06-23|1.7767|3.18|7.40|16.19|37.49|59.99|114.48|158.19|156.76|58.31|779.80|3|1|1|0.15|0||020,211|1|1|100元|1.50%|0.15%|0.15%|1","213001|宝盈鸿利收益灵活配置混合A|混合型|2020-06-23|2.0280|2.17|4.81|14.38|33.07|53.60|113.01|127.66|172.88|48.57|1,004.14|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","005689|中银医疗保健混合|混合型|2020-06-23|2.3956|2.35|4.84|19.61|42.67|60.26|112.75|145.40||55.50|145.52|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","005176|富国精准医疗混合|混合型|2020-06-23|2.8643|2.63|4.66|20.62|44.47|65.43|112.58|118.70||62.98|186.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002408|中信建投医改混合A|混合型|2020-06-23|2.1648|3.57|4.77|23.10|45.58|68.21|110.79|81.92|107.95|65.76|116.48|3|1|1|0.12|0||211|1|1|1000元|1.20%|0.12%|0.12%|1","320007|诺安成长混合|混合型|2020-06-23|1.6930|0.36|9.30|9.16|33.52|38.09|110.31|130.34|68.29|36.20|152.93|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","162703|广发小盘成长混合(LOF)A|混合型|2020-06-23|2.9038|1.55|4.60|11.69|26.44|46.04|110.15|121.17|126.35|42.97|1,131.50|3|1|1|0.15|0||020,211|1|1|10元|1.50%|0.15%|0.15%|1","519026|海富通中小盘混合|混合型|2020-06-23|1.5470|3.62|7.65|21.05|50.49|53.78|109.91|98.08|78.43|46.64|54.70|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000727|融通健康产业灵活配置混合A/B|混合型|2020-06-23|2.6680|1.18|5.29|20.02|45.63|69.72|108.93|140.58|168.14|64.29|166.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002482|宝盈互联网沪港深混合|混合型|2020-06-23|2.3670|2.16|7.35|18.71|35.80|40.64|107.45|111.53|137.65|36.98|136.70|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003095|中欧医疗健康混合A|混合型|2020-06-23|2.8430|2.97|4.87|20.88|56.04|66.65|106.76|95.40|177.98|64.05|199.66|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000452|南方医药保健灵活配置混合|混合型|2020-06-23|3.2800|3.40|5.13|23.12|54.43|66.92|106.68|99.63|115.36|62.62|290.91|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000924|宝盈先进制造混合A|混合型|2020-06-23|2.0310|2.37|4.96|14.29|32.26|51.62|106.28|122.67|155.62|46.47|157.41|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003096|中欧医疗健康混合C|混合型|2020-06-23|2.8310|2.98|4.85|20.78|55.72|65.94|106.04|94.97|177.61|63.36|198.43|3|0|1|0.00|0||211|1|1|100元||0.00%||","000220|富国医疗保健行业混合|混合型|2020-06-23|4.3460|3.13|5.18|17.91|46.08|63.69|105.48|102.52|152.97|60.78|334.60|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","161616|融通医疗保健行业混合A/B|混合型|2020-06-23|2.3610|2.79|4.93|20.21|51.93|72.34|105.48|91.02|128.12|68.40|226.74|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000717|融通转型三动力灵活配置混合|混合型|2020-06-23|2.7460|2.12|3.35|14.37|22.64|37.09|105.08|96.70|121.45|30.76|174.60|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","004374|华泰保兴吉年丰混合发起A|混合型|2020-06-23|1.8959|1.97|4.47|18.08|28.93|38.47|104.39|86.95|117.44|32.96|106.07|3|1|1|0.15|0||080,211|1|1|100元|1.50%|0.15%|0.15%|1","005805|华泰柏瑞医疗健康混合|混合型|2020-06-23|2.3471|2.88|4.31|22.31|53.00|66.18|104.34|||62.36|134.71|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","004375|华泰保兴吉年丰混合发起C|混合型|2020-06-23|1.8803|1.96|4.46|18.06|28.87|38.32|103.91|86.04|115.78|32.84|104.41|3|0|1|0.00|0||080,211|1|1|100元||0.00%||","000404|易方达新兴成长灵活配置|混合型|2020-06-23|3.9400|2.02|7.12|18.00|33.51|41.68|102.67|94.28|107.48|34.75|294.00|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002213|中海顺鑫灵活配置混合|混合型|2020-06-23|1.7816|2.08|5.33|15.73|34.16|55.88|102.66|97.60|81.86|48.74|84.04|3|1|1|0.08|0||211|1|1|100元|0.80%|0.08%|0.08%|1","007490|南方信息创新混合A|混合型|2020-06-23|2.0252|1.75|7.46|19.57|32.02|38.71|102.52|||35.00|102.52|0|1|1|0.15|0||211|0|6|100元|1.50%|0.15%|0.15%|1","460005|华泰柏瑞价值增长混合|混合型|2020-06-23|4.4214|2.78|4.76|14.88|32.18|45.06|101.73|98.70|112.46|42.13|738.38|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","007491|南方信息创新混合C|混合型|2020-06-23|2.0091|1.75|7.44|19.48|31.74|38.15|100.93|||34.48|100.91|0|0|1|0.00|0||211|0|6|100元||0.00%||","000339|长城医疗保健混合|混合型|2020-06-23|3.4616|2.21|4.58|19.23|36.22|56.73|99.94|120.43|135.32|52.50|246.16|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002560|诺安和鑫灵活配置混合|混合型|2020-06-23|1.4659|0.34|9.22|10.18|32.59|41.10|99.52|60.05|45.86|39.21|46.59|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","050026|博时医疗保健行业混合A|混合型|2020-06-23|3.7090|1.56|2.97|21.65|52.89|65.95|99.09|118.95|147.60|62.60|315.17|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","519773|交银数据产业灵活配置混合|混合型|2020-06-23|1.6910|1.20|4.45|14.64|24.16|38.61|98.94|131.96|104.72|34.53|69.10|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","270050|广发新经济混合|混合型|2020-06-23|3.8160|2.61|3.47|14.63|34.75|60.47|98.54|78.90|95.29|57.75|281.60|3|1|1|0.15|0||080,211|1|1|10元|1.50%|0.15%|0.15%|1","240020|华宝医药生物混合|混合型|2020-06-23|3.5860|3.46|5.81|20.74|48.49|59.73|97.79|88.74|120.41|56.25|347.18|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","004905|华泰柏瑞生物医药混合|混合型|2020-06-23|2.4287|3.21|5.00|18.14|48.53|61.67|97.49|101.62||57.82|142.87|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000977|长城环保主题混合|混合型|2020-06-23|1.8355|1.42|3.36|16.44|43.61|57.65|96.52|108.60|81.91|51.88|83.55|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","007340|南方科技创新混合A|混合型|2020-06-23|1.9702|0.53|3.59|13.94|26.38|38.52|96.51|||34.60|97.02|0|1|1|0.15|0||211,413|0|6|100元|1.50%|0.15%|0.15%|1","000031|华夏复兴混合|混合型|2020-06-23|2.8380|1.61|6.21|18.10|38.57|40.36|95.99|98.88|61.16|33.74|183.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","470006|汇添富医药保健混合A|混合型|2020-06-23|2.5800|3.16|5.35|20.73|52.12|60.95|95.50|78.49|111.37|57.89|235.32|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002264|华夏乐享健康混合|混合型|2020-06-23|2.1480|1.51|1.61|13.89|23.38|55.09|95.45|77.23|99.26|50.63|114.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001822|华商智能生活灵活配置混合|混合型|2020-06-23|1.5530|1.30|3.95|14.02|36.23|52.70|95.10|83.79|85.32|48.47|55.30|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002692|富国创新科技混合|混合型|2020-06-23|2.1840|3.61|9.31|18.95|34.15|44.35|95.00|132.34|130.62|41.45|118.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001069|华泰柏瑞消费成长混合|混合型|2020-06-23|2.1250|2.91|4.53|14.12|31.66|46.65|94.95|98.23|102.57|43.39|112.50|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000601|华宝创新优选混合|混合型|2020-06-23|1.8610|1.03|5.74|24.56|37.95|45.28|94.26|113.66|103.61|41.09|123.94|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","110023|易方达医疗保健行业混合|混合型|2020-06-23|3.4230|2.61|6.04|19.73|46.66|58.84|93.72|88.08|144.15|55.45|242.30|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","161810|银华内需精选混合(LOF)|混合型|2020-06-23|3.0120|-0.20|7.53|12.10|31.18|42.34|93.45|121.63|89.20|37.16|201.20|3|1|1|0.15|0||020,211|1|1|100元|1.50%|0.15%|0.15%|1","002708|大摩健康产业混合|混合型|2020-06-23|2.4440|2.99|6.54|16.44|38.63|56.47|92.59|92.74|135.45|53.04|144.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","005311|万家经济新动能混合A|混合型|2020-06-23|2.1257|2.28|8.37|12.55|33.21|62.01|92.42|112.44||55.89|112.57|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","006881|华宝大健康混合|混合型|2020-06-23|1.8897|3.40|5.38|19.60|47.53|63.45|91.96|||59.11|88.97|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","519642|银河智造混合|混合型|2020-06-23|2.2720|3.18|8.09|18.64|31.94|51.47|91.57|80.32|111.15|48.79|127.20|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001210|天弘互联网混合|混合型|2020-06-23|1.1440|0.47|7.88|12.13|19.12|37.63|91.43|94.13|85.14|35.56|14.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002124|广发新兴产业混合|混合型|2020-06-23|2.4830|1.35|3.76|14.90|39.97|58.66|91.29|95.05|105.21|52.05|148.30|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001558|天弘医疗健康混合A|混合型|2020-06-23|1.6457|2.75|4.25|19.17|42.69|58.04|91.20|79.94|128.00|54.05|64.57|3|1|1|0.12|0||211|1|1|100元|1.20%|0.12%|0.12%|1","005312|万家经济新动能混合C|混合型|2020-06-23|2.0834|2.28|8.36|12.50|33.04|61.62|91.19|108.19||55.52|108.34|3|0|1|0.00|0||211|1|1|100元||0.00%||","006113|汇添富创新医药混合|混合型|2020-06-23|2.4665|3.13|5.60|19.39|49.48|57.51|91.19|||54.44|146.65|0|1|1|0.15|0||211|0|6|100元|1.50%|0.15%|0.15%|1","001513|易方达信息产业混合|混合型|2020-06-23|2.2600|2.26|7.47|16.32|26.40|35.57|91.04|113.21|112.01|32.01|126.00|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","519670|银河行业混合|混合型|2020-06-23|1.9860|2.32|8.52|17.03|50.23|52.41|90.99|78.96|78.05|48.16|528.82|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003516|国泰融安多策略灵活配置混合|混合型|2020-06-23|2.3828|2.25|1.66|14.67|32.25|41.97|90.56|123.28||37.38|138.28|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","005028|鹏华研究精选灵活配置混合|混合型|2020-06-23|1.8986|2.20|4.00|12.74|40.57|55.33|90.49|99.06||48.65|89.86|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001559|天弘医疗健康混合C|混合型|2020-06-23|1.6190|2.75|4.24|19.12|42.56|57.72|90.43|78.50|125.52|53.75|61.90|3|0|1|0.00|0||211|1|1|100元||0.00%||","001815|华泰柏瑞激励动力混合A|混合型|2020-06-23|2.5590|3.14|4.66|18.47|46.65|62.58|90.12|87.06|127.31|57.87|168.22|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002669|华商万众创新混合|混合型|2020-06-23|1.5530|1.70|1.97|13.86|31.95|54.22|90.09|107.90|92.92|47.90|55.30|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","163001|长信医疗保健混合(LOF)|混合型|2020-06-23|1.8080|2.67|2.61|19.66|46.28|62.15|89.92|78.13|100.00|58.74|186.69|3|1|1|0.15|0||020,211|1|1|100元|1.50%|0.15%|0.15%|1","270028|广发制造业精选混合|混合型|2020-06-23|4.0380|0.80|5.24|15.64|36.97|44.63|89.67|90.38|71.90|39.43|303.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003291|信达澳银健康中国混合|混合型|2020-06-23|1.9050|2.81|5.25|18.62|55.00|59.28|89.55|87.87||56.53|90.50|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000939|中银研究精选灵活配置混合|混合型|2020-06-23|1.3670|3.40|6.55|17.34|43.14|46.83|89.34|88.81|90.66|44.66|67.53|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001508|富国新动力灵活配置混合A|混合型|2020-06-23|3.1790|1.99|5.47|14.93|31.74|44.50|89.00|112.50|168.04|42.30|217.90|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002082|华泰柏瑞激励动力混合C|混合型|2020-06-23|2.8380|3.16|4.68|18.45|46.52|62.36|88.95|85.01|124.22|57.67|194.80|3|0|1|0.00|0||211|1|1|100元||0.00%||","001510|富国新动力灵活配置混合C|混合型|2020-06-23|3.1220|1.96|5.44|14.86|31.56|44.07|88.07|110.66|164.80|41.97|212.20|3|0|1|0.00|0||211|1|1|100元||0.00%||","213006|宝盈核心优势混合A|混合型|2020-06-23|1.2506|2.56|7.05|15.49|24.35|36.50|87.93|96.22|88.90|33.16|311.01|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001480|财通成长优选混合|混合型|2020-06-23|1.6640|0.73|5.79|16.77|24.36|34.85|87.81|116.95|86.76|32.91|66.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","006218|富国生物医药科技混合|混合型|2020-06-23|1.9063|2.63|5.29|21.57|45.85|60.99|87.76|||59.63|90.63|0|1|1|0.15|0||211|0|6|100元|1.50%|0.15%|0.15%|1","410003|华富成长趋势混合|混合型|2020-06-23|1.6649|1.96|4.63|17.69|27.79|55.38|87.69|87.90|100.43|51.26|118.86|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","006314|中融策略优选混合A|混合型|2020-06-23|1.9029|2.19|5.13|16.49|38.32|45.05|87.64|||39.92|90.29|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","501046|财通多策略福鑫定开混合|混合型|2020-06-23|1.9543|0.69|5.85|17.90|25.58|35.86|87.23|117.39||33.28|95.41|0|1|1|0.15|0||070,071,080,211|0|6|1000元|1.50%|0.15%|0.15%|1","001864|中海魅力长三角混合|混合型|2020-06-23|2.0510|2.29|5.83|13.31|30.80|48.30|87.14|91.15|87.99|41.74|105.10|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003032|平安医疗健康混合|混合型|2020-06-23|1.8377|2.36|4.92|19.63|47.84|60.55|87.12|75.00||57.30|83.75|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","550009|信诚中小盘混合|混合型|2020-06-23|2.5190|1.33|6.96|13.52|24.15|37.58|87.01|83.33|77.14|32.30|184.62|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000698|宝盈科技30混合|混合型|2020-06-23|2.5620|1.83|6.71|15.35|30.91|31.25|87.01|81.70|77.06|27.15|156.20|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000073|上投摩根成长动力混合|混合型|2020-06-23|2.0470|2.71|5.30|19.01|43.35|43.75|86.60|59.67|71.58|39.92|104.70|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","006736|国投瑞银先进制造混合|混合型|2020-06-23|1.8218|2.03|7.44|23.18|35.50|40.25|86.28|||32.70|82.18|0|1|1|0.15|0||211|0|6|100元|1.50%|0.15%|0.15%|1","290011|泰信中小盘精选混合|混合型|2020-06-23|2.8850|2.23|6.61|10.28|27.60|45.34|86.25|99.38|67.93|40.39|237.52|3|1|1|0.15|0||211|1|1|1000元|1.50%|0.15%|0.15%|1","720001|财通价值动量混合|混合型|2020-06-23|3.2530|0.84|6.03|15.68|23.13|35.26|86.20|117.45|92.61|33.16|331.00|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001861|富安达健康人生混合|混合型|2020-06-23|2.0445|1.77|5.38|24.16|45.79|55.46|86.15|74.10|104.70|51.50|104.45|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","001701|中融产业升级混合|混合型|2020-06-23|1.8680|2.24|5.48|17.19|37.15|50.40|86.06|88.31|91.98|43.25|86.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","004895|华商鑫安灵活混合|混合型|2020-06-23|1.3530|1.88|2.50|14.27|33.56|55.71|85.98|64.29||50.18|52.13|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002160|南方驱动混合|混合型|2020-06-23|2.3990|1.61|3.94|14.95|34.02|41.78|85.97|78.76|93.00|38.59|139.90|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","003581|前海联合国民健康混合A|混合型|2020-06-23|1.7380|2.48|6.56|16.41|39.37|57.29|85.88|57.43|67.92|53.40|73.80|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","002446|广发利鑫灵活配置混合|混合型|2020-06-23|2.0580|1.78|3.89|15.49|43.41|55.44|85.57|92.88|99.23|49.13|105.80|3|1|1|0.10|0||211|0|1|100元|1.00%|0.10%|0.10%|1","000362|国泰聚信价值优势混合A|混合型|2020-06-23|2.2980|1.91|2.68|19.44|27.81|52.79|85.47|95.57|97.08|46.93|322.36|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","006315|中融策略优选混合C|混合型|2020-06-23|1.8798|2.19|5.13|16.45|38.19|44.59|85.42|||39.50|87.98|3|0|1|0.00|0||211|1|1|100元||0.00%||","377240|上投摩根新兴动力混合A|混合型|2020-06-23|4.5800|1.82|5.87|18.50|37.58|46.61|85.28|75.75|87.94|41.80|358.00|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","519171|浦银安盛医疗健康混合|混合型|2020-06-23|1.4940|2.33|2.96|20.58|46.47|59.28|85.13|75.56|102.99|56.77|49.40|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","519133|海富通改革驱动混合|混合型|2020-06-23|1.8860|0.75|2.61|16.13|32.91|42.13|85.08|98.32|99.71|36.08|122.08|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","200012|长城中小盘成长混合|混合型|2020-06-23|2.5804|2.49|4.60|14.73|32.44|52.23|84.94|78.80|99.41|48.62|158.04|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1","000940|富国中小盘精选混合|混合型|2020-06-23|2.1950|1.06|6.14|14.50|26.51|42.16|84.76|83.99|89.88|37.70|119.50|3|1|1|0.15|0||211|0|1|100元|1.50%|0.15%|0.15%|1","000363|国泰聚信价值优势混合C|混合型|2020-06-23|2.3160|1.94|2.66|19.44|27.67|52.37|84.69|93.81|94.13|46.68|325.05|3|0|1|0.00|0||211|1|1|100元||0.00%||","000541|华商创新成长混合发起式|混合型|2020-06-23|2.0480|1.84|1.99|13.59|31.45|49.16|84.50|100.39|54.57|43.52|149.38|3|1|1|0.15|0||080,211|1|1|100元|1.50%|0.15%|0.15%|1","001704|国投瑞银进宝灵活配置混合|混合型|2020-06-23|1.8521|2.00|6.88|22.07|34.01|33.84|84.31|87.55|85.37|27.44|89.82|3|1|1|0.15|0||211|1|1|100元|1.50%|0.15%|0.15%|1"],allRecords:3440,pageIndex:1,pageNum:100,allPages:35};

咋一看,以为这是字典,就想用eval,values取操作取内容,后来发现自己想多了。我们答应这个内容,不难看出它是字符串形式。对于字符串的处理:
下面分几步走:
1.找到我们需要的内容:在[ 内容]里面。
2.将每一个基金转变成列表
3.取每一个基金里的值。
这里直接上代码:

result=resp.text#获取到花括号{}里面的数 left=result.index('[') right=result.index(']') content=result[left+1:right] i = 1 a="','" weizhi = content.find(a) if weizhi: content=content.replace(content[weizhi],"?") #循环查找并替换“,” i=i+1 content = content.replace(",?", "") content=content.split("|") content = str(content).replace("?", "']?['") content = content.replace("?", '","') content=content[6:] content=content[:-6] contents=(eval(content)) for s in contents: results=eval(s) aa=results[0] bb=results[1] cc=results[4] dd=results[3] ee=results[5] ff=results[6] gg=results[7] hh=results[8] ii=results[9] jj=results[10] kk=results[11] ll=results[12] mm=results[13] nn=results[14] oo=results[18] pp=results[24] rows=[aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp] sheet.append(rows)

上面代码中对于content的操作是精华部分,大家可以慢慢吸收体会,最好是可以自己去尝试一下。这里只提供了爬取我内容的部分,对于表头的获取直接采用BeautifulSoup或者Xpath,再或者正则都能轻松搞定,这里就不详细介绍,需要所有源码的同学也可以私信。

【1】https://www.cnblogs.com/yuhoucaihong/p/10185691.html
【2】https://blog.csdn.net/weixin_42393585/article/details/101198125

本文来源:https://www.thyysj.com/info/396659.html

标签组:[基金] [混合型基金] [天天基金

相关APP下载

热门话题

健康养生推荐文章

健康养生热门文章