python urllib2爬虫短时间访问同一个网站 被拒绝 求教,pythonurllib2, user_age
python urllib2爬虫短时间访问同一个网站 被拒绝 求教,pythonurllib2, user_age
user_agent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)" headers = {'User-Agent': user_agent,'Host':"ggjd.cnstock.com",'DNT':'1'}resp=None raw_content="" try: resp=urllib2.urlopen(req,timeout=10) except urllib2.URLError as e: if hasattr(e,'code'): print "Error code : %s" %e.code elif hasattr(e,'reason'): print "Error reason : %s" %e.reason finally: if resp: raw_content = resp.read() time.sleep(1) resp.close()
最后还是没有得到任何的error信息。 听说代理可以解决?
编橙之家文章,
相关内容
- 在启动ipython notebook时候 终端提示这样的错误,请问如
- 动态生成对象问题请教 (flask-sqlalchemy引出的python基本
- python 爬虫爬wiki 报错 [Errno 65] No route to host,pythonerrno
- 再次请教个flasksqlalchemy的表及字段问题,,class SpeedD
- python 第三方库requests连接url报错,pythonrequests,使用的语
- 今天两次遇到python里不同程序调同一模块,输入相同结
- Django: 路由与视图题的问题,django路由视图题,简介Dja
- wtforms 表单表单验证异常,不知如何解决,wtforms表单
- codecademy,ideone.com/等在线测试js,php,ruby,python是怎么实现的
- 个人博客站点如何上传文章(非WordPress),博客wordpr
评论关闭