关于正则表达提取文本的问题
all_info = re.search(r'window.__SEARCH_RESULT__ = ([\d\D]*)',res.text)print(all_info)
print(all_info.group(1))
window.__SEARCH_RESULT__ = {"top_ads":[],"auction_ads":[],"market_ads":[],"engine_jds":[{"type":"engine_jds","jt":"0_0","tags":[],"ad_track":"","jobid":"135077337","coid":"2758227","effect":"1","is_special_job":"","job_href":"https:\/\/jobs.51job.com\/beijing\/135077337.html?s=sou_sou_soulb&t=0_0","job_name":"法证数据分析师","job_title":"法证数据分析师","company_href":"https:\/\/jobs.51job.com\/all\/co2758227.html","company_name":"字节跳动","providesalary_text":"2-3万\/月","workarea":"010000","workarea_text":"北京","updatedate":"09-07","iscommunicate":"","companytype_text":"民营公司","degreefrom":"6","workyear":"5","issuedate":"2021-09-07 02:58:01","isFromXyz":"","isIntern":"","jobwelf":"下午茶 健身瑜伽 六险一金 团队氛围好 晋升空间大 扁平管理 大牛带队 免费三餐 弹性工作 租房补贴","jobwelf_list":["下午茶","健身瑜伽","六险一金","团队氛围好","晋升空间大","扁平管理","大牛带队","免费三餐","弹性工作","租房补贴"],"isdiffcity":"","attribute_text":["北京","3-4年经验","本科","招1人"],"companysize_text":"10000人以上","companyind_text":"互联网\/电子商务","adid":""},{"type":"engine_jds","jt":"0_0","tags":[],"ad_track":"","jobid":"134908361","coid":"3881099","effect":"1","is_special_job":"","job_href":"https:\/\/jobs.51job.com\/beijing-cyq\/134908361.html?s=sou_sou_soulb&t=0_0","job_name":"数据分析师","job_title":"数据分析师","company_href":"https:\/\/jobs.51job.com\/all\/co3881099.html","company_name":"睿尔博汽车信息服务(北京)有限公司","providesalary_text":"5-8千\/月","workarea":"010500","workarea_text":"北京-朝阳区","updatedate":"09-07","iscommunicate":"","companytype_text":"外资(非欧美)","degreefrom":"5","workyear":"3","issuedate":"2021-09-07 04:01:18","isFromXyz":"","isIntern":"","jobwelf":"五险一金 补充医疗保险 餐饮补贴 定期体检 弹性工作 年终奖金","jobwelf_list":["五险一金","补充医疗保险","餐饮补贴","定期体检","弹性工作","年终奖金"],"isdiffcity":"","attribute_text":["北京-朝阳区","1年经验","大专","招1人"],"companysize_text":"150-500人","companyind_text":"专业服务(咨询、人力资源、财会)","adid":""},{"type":"engine_jds","jt":"0_0","tags":[],"ad_track":"","jobid":"134907842","coid":"6734015","effect":"1","is_special_job":"","job_href":"https:\/\/jobs.51job.com\/beijing\/134907842.html?s=sou_sou_soulb&t=0_0","job_name":"数据分析师","job_title":"数据分析师","company_href":"https:\/\/jobs.51job.com\/all\/coAmIGZQdnBT9UMVEzXDw.html","company_name":"北京融七牛信息技术有限公司","providesalary_text":"1.5-2万\/月","workarea":"010000","workarea_text":"北京","updatedate":"09-07","iscommunicate":"","companytype_text":"民营公司","degreefrom":"6","workyear":"4","issuedate":"2021-09-07 04:01:18","isFromXyz":"","isIntern":"","jobwelf":"","jobwelf_list":[""],"isdiffcity":"","attribute_text":["北京","2年经验","本科","招若干人"],"companysize_text":"少于50人","companyind_text":"互联网\/电子商务","adid":""},{"type":"engine_jds","jt":"0_1","tags":
如何才能提取出window.__SEARCH_RESULT__ 字典里的东西呢,为什么用上面的方法print(all_info.group(1))把所有的res.text都打印出来了 把所有代码发出来,这个看起来数据不全。 1。你想要啥内容
2.[\d\D]*
\d -> 匹配数字
\D->匹配数字以外
*->匹配次数零次或多次
页:
[1]