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

来源:3-2 使用urllib发送post请求

一往无前001

2019-02-27 00:12

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


写回答 关注

2回答

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

    如图所示

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


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

python遇见数据采集

本教程让你初步掌握Python进行数据采集,创造属于你的价值

59669 学习 · 200 问题

查看课程

相似问题