| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2594 人关注过本帖
标题:新手在初学爬虫内容时遇到Python问题,希望各位能赐教
取消只看楼主 加入收藏
xuh
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-1-1
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
新手在初学爬虫内容时遇到Python问题,希望各位能赐教
图片附件: 游客没有浏览图片的权限,请 登录注册



程序代码:

import urllib.request
proxy_handler = urllib.request.ProxyHandler(
    {
        'http': 'http://127.0.0.1:9743',
        'https': 'https://127.0.0.1:9743'
    }
)
opener = urllib.request.build_opener(proxy_handler)
response = opener.open('http://www.baidu.com')
print(response.read())


出现以下错误结果:
C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/Administrator/AppData/Local/Programs/Python/Python37-32/spiders/基本库的使用.py
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 956, in send
    self.connect()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 928, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 727, in create_connection
    raise err
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。


请问如何解决???
搜索更多相关主题的帖子: Python lib Users Local File 
2019-01-01 15:36
xuh
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-1-1
收藏
得分:0 
回复 3楼 guanyaohao
因为是新手,按照书一步步学的(小尴尬)
2019-01-03 18:56
快速回复:新手在初学爬虫内容时遇到Python问题,希望各位能赐教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018592 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved