擅长:python、mysql、java
<p>我想这就是你想要的:</p>
<pre><code>import urllib2
u = 'http://www.google.com/'
pages = open('pages.txt', 'r').readlines()
for page in pages:
url = u+page
try:
req = urllib2.urlopen(url)
except urllib2.HTTPError as e:
if e.code == 404:
print url+" does not exists"
else:
print url+" exists"
</code></pre>
<p>使用包含以下内容的<code>pages.txt</code>文件进行测试:</p>
<pre><code>search
page
plus
signin
account
security
lol
about
someotherpage.html
</code></pre>