ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 541|回复: 3

[求助] 用论坛的案例获取JSL网页提示游客登录无法获取全部数据

[复制链接]

TA的精华主题

TA的得分主题

发表于 2021-7-27 17:10 | 显示全部楼层 |阅读模式
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
本帖最后由 bobonone 于 2021-7-27 17:14 编辑

我在论坛帖子http://club.excelhome.net/thread-1536860-1-1.html中根据大神deadzlq的“PQ爬取【可转债 - 可转债 - 集思录】数据.rar”用来获取JSL的可转债数据,之前一直用的好好的,今天开始只能获取前30的数据, 1627376813.png ,看了显示现在需要登录才能显示完整信息,不过自己是个菜鸟只会抄大神的代码,也不知道如何才能添加cookie,还请各位大神不吝赐教,谢谢 PQ爬取【可转债 - 可转债 - 集思录】数据.rar (183.77 KB, 下载次数: 3)
  1. let
  2.     Timestamp=Text.Start(Text.From(Duration.TotalSeconds(DateTime.LocalNow()-#datetime(1970,1,1,8,0,0))*1000),13),
  3.     Url="https://www.jisilu.cn/data/cbnew/cb_list/?___jsl=LST___t=" & Timestamp,
  4.     Source = Table.FromRecords(Json.Document(Web.Contents(Url,[Headers=[Referer="https://www.jisilu.cn/data/cbnew/"]]))[rows]),
  5.     getCols = List.Distinct(List.Combine(List.Transform(Source[cell],Record.FieldNames))),
  6.     Result = Table.ExpandRecordColumn(Source , "cell", getCols ,getCols ),
  7.     删除的列 = Table.RemoveColumns(Result,{"id"}),
  8.     重排序的列 = Table.ReorderColumns(删除的列,{"bond_id", "bond_nm", "price", "stock_id", "stock_nm", "btype", "convert_price", "convert_price_valid_from", "convert_dt", "maturity_dt", "next_put_dt", "put_dt", "put_notes", "put_price", "put_inc_cpn_fl", "put_convert_price_ratio", "put_count_days", "put_total_days", "put_real_days", "repo_discount_rt", "repo_valid_from", "repo_valid_to", "turnover_rt", "pb", "redeem_price", "redeem_inc_cpn_fl", "redeem_price_ratio", "redeem_count_days", "redeem_total_days", "redeem_real_days", "redeem_dt", "redeem_flag", "orig_iss_amt", "curr_iss_amt", "rating_cd", "issuer_rating_cd", "guarantor", "ssc_dt", "esc_dt", "sc_notes", "market_cd", "force_redeem", "real_force_redeem_price", "convert_cd", "repo_cd", "ration", "ration_cd", "apply_cd", "online_offline_ratio", "qflag", "qflag2", "ration_rt", "fund_rt", "margin_flg", "lt_bps", "pb_flag", "total_shares", "float_shares", "sqflg", "sprice", "svolume", "sincrease_rt", "qstatus", "bond_value", "bond_value2", "volatility_rate", "last_time", "convert_value", "premium_rt", "year_left", "ytm_rt", "ytm_rt_tax", "full_price", "increase_rt", "volume", "convert_price_valid", "adj_scnt", "adj_cnt", "redeem_icon", "ref_yield_info", "adjust_tip", "adjusted", "option_tip", "bond_value3", "left_put_year", "short_maturity_dt", "dblow", "force_redeem_price", "put_convert_price", "convert_amt_ratio", "convert_amt_ratio2", "convert_amt_ratio_tips", "stock_net_value", "stock_cd", "pre_bond_id", "repo_valid", "convert_cd_tip", "price_tips"}),
  9.     删除的列1 = Table.RemoveColumns(重排序的列,{"stock_id"}),
  10.     重排序的列1 = Table.ReorderColumns(删除的列1,{"bond_id", "bond_nm", "price", "increase_rt", "stock_cd", "stock_nm", "sprice", "sincrease_rt", "convert_price", "premium_rt", "pb", "rating_cd", "curr_iss_amt", "year_left", "maturity_dt", "ytm_rt", "convert_amt_ratio", "dblow", "btype", "convert_price_valid_from", "convert_dt", "next_put_dt", "put_dt", "put_notes", "put_price", "put_inc_cpn_fl", "put_convert_price_ratio", "put_count_days", "put_total_days", "put_real_days", "repo_discount_rt", "repo_valid_from", "repo_valid_to", "turnover_rt", "redeem_price", "redeem_inc_cpn_fl", "redeem_price_ratio", "redeem_count_days", "redeem_total_days", "redeem_real_days", "redeem_dt", "redeem_flag", "orig_iss_amt", "issuer_rating_cd", "guarantor", "ssc_dt", "esc_dt", "sc_notes", "market_cd", "force_redeem", "real_force_redeem_price", "convert_cd", "repo_cd", "ration", "ration_cd", "apply_cd", "online_offline_ratio", "qflag", "qflag2", "ration_rt", "fund_rt", "margin_flg", "lt_bps", "pb_flag", "total_shares", "float_shares", "sqflg", "svolume", "qstatus", "bond_value", "bond_value2", "volatility_rate", "last_time", "convert_value", "ytm_rt_tax", "full_price", "volume", "convert_price_valid", "adj_scnt", "adj_cnt", "redeem_icon", "ref_yield_info", "adjust_tip", "adjusted", "option_tip", "bond_value3", "left_put_year", "short_maturity_dt", "force_redeem_price", "put_convert_price", "convert_amt_ratio2", "convert_amt_ratio_tips", "stock_net_value", "pre_bond_id", "repo_valid", "convert_cd_tip", "price_tips"}),
  11.     删除的列2 = Table.RemoveColumns(重排序的列1,{"btype", "convert_price_valid_from", "convert_dt", "next_put_dt", "put_dt", "put_notes", "put_price", "put_inc_cpn_fl", "put_convert_price_ratio", "put_count_days", "put_total_days", "put_real_days", "repo_discount_rt", "repo_valid_from", "repo_valid_to", "turnover_rt", "redeem_price", "redeem_inc_cpn_fl", "redeem_price_ratio", "redeem_count_days", "redeem_total_days", "redeem_real_days", "redeem_dt", "redeem_flag", "orig_iss_amt", "issuer_rating_cd", "guarantor", "ssc_dt", "esc_dt", "sc_notes", "market_cd", "force_redeem", "real_force_redeem_price", "convert_cd", "repo_cd", "ration", "ration_cd", "apply_cd", "online_offline_ratio", "qflag", "qflag2", "ration_rt", "fund_rt", "margin_flg", "lt_bps", "pb_flag", "total_shares", "float_shares", "sqflg", "svolume", "qstatus", "bond_value", "bond_value2", "volatility_rate", "last_time", "convert_value", "ytm_rt_tax", "full_price", "volume", "convert_price_valid", "adj_scnt", "adj_cnt", "redeem_icon", "ref_yield_info", "adjust_tip", "adjusted", "option_tip", "bond_value3", "left_put_year", "short_maturity_dt", "force_redeem_price", "put_convert_price", "convert_amt_ratio2", "convert_amt_ratio_tips", "stock_net_value", "pre_bond_id", "repo_valid", "convert_cd_tip", "price_tips"}),
  12.     排序的行 = Table.Sort(删除的列2,{{"dblow", Order.Ascending}}),
  13.     更改的类型 = Table.TransformColumnTypes(排序的行,{{"price", type number}, {"increase_rt", Percentage.Type}, {"sprice", type number}, {"sincrease_rt", Percentage.Type}, {"convert_price", type number}, {"premium_rt", Percentage.Type}, {"pb", type number}, {"curr_iss_amt", type number}, {"year_left", type number}, {"maturity_dt", type date}, {"ytm_rt", Percentage.Type}, {"convert_amt_ratio", Percentage.Type}, {"dblow", type number}}),
  14.     重命名的列 = Table.RenameColumns(更改的类型,{{"bond_id", "转债代码"}, {"bond_nm", "转债名称"}, {"price", "现价"}, {"increase_rt", "涨跌幅"}, {"stock_cd", "正股代码"}, {"stock_nm", "正股名称"}, {"sprice", "正股价"}, {"sincrease_rt", "正股涨跌"}, {"convert_price", "转股价"}, {"premium_rt", "溢价率"}, {"rating_cd", "评级"}, {"curr_iss_amt", "剩余规模"}, {"year_left", "剩余年限"}, {"maturity_dt", "到期日期"}, {"ytm_rt", "到期税前收益"}, {"convert_amt_ratio", "转债占比"}, {"dblow", "双低值"}}),
  15.     排序的行1 = Table.Sort(重命名的列,{{"双低值", Order.Ascending}})
  16. in
  17.     排序的行1
复制代码


TA的精华主题

TA的得分主题

发表于 2021-7-27 19:11 | 显示全部楼层
= Json.Document(Web.Contents("https://myapp.example.com/api/test.php", [Headers=[Cookie="PHPSESSID=123abc"]]))

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-7-27 21:37 | 显示全部楼层
hyzhangyong 发表于 2021-7-27 19:11
= Json.Document(Web.Contents("https://myapp.example.com/api/test.php", [Headers=[Cookie="PHPSESSID=1 ...

谢谢大神指教,可惜是个小白,不明白哪个是cookie, 1627392893(1).png ,请问是这样改吗= Json.Document(Web.Contents("https://www.jisilu.cn/data/cbnew/cb_list/?", [Headers=[Cookie="PHPSESSID=*****"]]))

TA的精华主题

TA的得分主题

发表于 2021-7-28 09:55 | 显示全部楼层
打开网页,按F12,刷新一下,如图所示就是cookie
QQ图片20210728095458.png

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-16 00:36 , Processed in 1.060789 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表