我试图抓住这个页面: http://photo.net/nikon-camera-forum/00aoms 我在Python中使用了Requests Package但是虽然页面很好但是当我在浏览器中输入url时它会加载我得到这个错误作为requests.get.text的输出而我不知道是什么&问题是:
"photo.net Temporarily Unavailable
photo.net
Sun Jul 13 19:26:33 EDT 2014 — photo.net is down temporarily for
system maintenance. Please visit us again later."
答案 0 :(得分:2)
该网站有一个简单的User-Agent
标题检查,provide it:
>>> import requests
>>> response = requests.get('http://photo.net/nikon-camera-forum/00aoms', headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4)'})
>>> print response.text
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<title>D800 wifi options? - Photo.net Nikon Forum</title>
...
仅供参考,没有通过标题:
>>> response = requests.get('http://photo.net/nikon-camera-forum/00aoms')
>>> print response.text
<html><head><title>photo.net Temporarily Unavailable</title></head>
<center><h2>photo.net </h2>
<p><i>Sun Jul 13 19:46:33 EDT 2014</i> — photo.net is down temporarily for
system maintenance. Please visit us again later.
</center>
</body>
</html>