问答详情
源自:3-2 使用urllib发送post请求

403是被发现是爬虫拒绝访问了吗? 不知道哪里出错了 有没有朋友帮忙看下

https://img1.mukewang.com/5c7565300001271610020505.jpg

https://img.mukewang.com/5c7565060001775f09890624.jpg

F:\python\python.exe F:/pycharm/new/ne.py

Traceback (most recent call last):

  File "F:/pycharm/new/ne.py", line 16, in <module>

    resp = urlopen(req, data=postData.encode('utf-8'))

  File "F:\python\lib\urllib\request.py", line 162, in urlopen

    return opener.open(url, data, timeout)

  File "F:\python\lib\urllib\request.py", line 471, in open

    response = meth(req, response)

  File "F:\python\lib\urllib\request.py", line 581, in http_response

    'http', request, response, code, msg, hdrs)

  File "F:\python\lib\urllib\request.py", line 509, in error

    return self._call_chain(*args)

  File "F:\python\lib\urllib\request.py", line 443, in _call_chain

    result = func(*args)

  File "F:\python\lib\urllib\request.py", line 589, in http_error_default

    raise HTTPError(req.full_url, code, msg, hdrs, fp)

urllib.error.HTTPError: HTTP Error 403: Forbidden


Process finished with exit code 1


提问者:一往无前001 2019-02-27 00:12

个回答

  • M448
    2019-03-31 18:11:55

    如图所示

  • M448
    2019-03-31 18:11:10


    你代码的postData中的key value和这个图里的要一模一样,貌似你写的不一致