浮生一日研究所 2021-06-07 20:44 采纳率: 100%
浏览 24
已采纳

post爬虫不理解地方

这个网站https://cmispub.cicpa.org.cn/cicpa2_web/public/query0/2/00.shtml

我写的代码如下;

import requests
from urllib.parse import urlencode

'''1、用requests解析网页数据'''
headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.56'}
def posturl2(url,data):
    r=requests.post(url,data,headers=headers)
    return r.text
url='https://cmispub.cicpa.org.cn/cicpa2_web/PersonIndexAction.do'
data2={'method': 'indexQuery',
'queryType': 2,
'isStock': '00',
'ascGuid': '湖北注协'.encode('gbk'),
'offName':'湖北华审会计师事务有限公司'.encode('gbk'),
'perCode':420601282585,
'perName':'刘斌'.encode('gbk')}
print(posturl2(url,urlencode(data2)))

弄出来依然查询不到 感谢

 

<script> var webPath="/cicpa2_web"; var imgPath="/cicpa2_web/images"; var skinPath="/cicpa2_web/skin/orange"; var eggImgs = "C97907DB0B28C437026E2C6A78659C89"; eggImgs = eggImgs.split(';'); </script> <script language="javascript" src="/cicpa2_web/script/common/common.js"></script> <script language="javascript" src="/cicpa2_web/script/message/message.js"></script> <link href="/cicpa2_web/skin/orange/css/skin.css" type="text/css" rel="stylesheet"> <link href="/cicpa2_web/css/common.css" type="text/css" rel="stylesheet"> <script> var imgDirSrc = webPath+"/images/popcalendar/"; </script> <script language="javascript" src="/cicpa2_web/script/common/common_bns.js"></script> <link href="/cicpa2_web/css/common_bns.css" type="text/css" rel="stylesheet"> <!-- description:错误异常页面 Author: xionghongliang date: 2007-7-31 --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>错误异常页面</title> <style> /*错误异常页面*/ .error_flag{ border:#CDCDCD 1px solid; border-bottom-width: 0; width: 400px; height: 200px; text-align: center; } .error_info{ border: #CDCDCD 1px solid; width: 400px; overflow:auto; background: #F9F9F9; } .error_info table tr td{ color: #f00; } </style> </head> <body > <table align="center" height="80%" cellpadding="0" cellspacing="0"> <tr><td valign="middle"> <div class="error_flag"> <table height="100%"><tr><td valign="middle"><img src="/cicpa2_web/ccp/auth/images/npaapply/pic-02.gif" /></td></tr></table> </div> <div class="error_info"> <span style="display:block;font-weight:bold;margin-top:3px;height:15px;">[提示信息]</span> <table height="110px"><tr><td valign="middle">非法请求</td></tr></table> </div> </td></tr> </table> </body> </html> <script type="text/javascript"> function JumpContactPhone(){ // 考生选择现场审核的需要显示咨询电话的连接 //window.open("https://cmispub.cicpa.org.cn/cicpa2_web/tz/04/01/0000016C429BD75B460A7945D77728FC.shtml"); window.location.href= "/cicpa2_web/FzybgAction.do?method=downloadAssociationContactPdf&datetime=1623080155667"; } </script>

  • 写回答

3条回答 默认 最新

  • CSDN专家-HGJ 2021-06-07 23:08
    关注

    1.data2里字典值都要写成字符串:2..headers要传Accept健值对。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 通信专业本科生论文选这两个哪个方向好研究呀
  • ¥50 我在一个购物网站的排队系统排队,这个排队到号后重新定向到目标网站进行购物,但是有技术牛通过技术方法直接跳过排队系统进入目标网址购物,有没有什么软件或者脚本可以用
  • ¥15 ios可以实现ymodem-1k协议 1024字节传输吗?
  • ¥300 寻抓云闪付tn组成网页付款链接
  • ¥15 请问Ubuntu要怎么安装chrome呀?
  • ¥15 视频编码 十六进制问题
  • ¥15 unity terrain打包后地形错位,跟建筑不在同一个位置,怎么办
  • ¥15 uniapp实现如下图的图表功能
  • ¥15 u-subsection如何修改相邻两个节点样式
  • ¥15 服务端控制goose报文控制块的发布问题