我正在尝试制作基本的网络爬虫。我的互联网是通过代理连接。所以我使用了给定的解决方案here。但仍然在运行代码时出现错误。 我的代码是:缓存访问被拒绝。请求模块中需要身份验证
#!/usr/bin/python3.4
import requests
from bs4 import BeautifulSoup
import urllib.request as req
proxies = {
"http": r"http://usr:[email protected]:3128",
"https": r"http://usr:[email protected]:3128",
}
url = input("Ask user for something")
def santabanta(max_pages,url):
page = 1
while (page <= max_pages):
source_code = requests.get(url,proxies=proxies)
plain_text = source_code.text
print (plain_text)
soup = BeautifulSoup(plain_text,"lxml")
for link in soup.findAll('a'):
href = link.get('href')
print(href)
page = page + 1
santabanta(1,url)
但是,尽管在Ubuntu 14.04在终端中运行我收到以下错误:http://www.santabanta.com/wallpapers/gauhar-khan/:
是试图获取URL遇到以下错误?
缓存访问被拒绝。
对不起,你目前被允许请求http://www.santabanta.com/wallpapers/gauhar-khan/?从这个缓存直到你已经认证你自己。
发表我的网址是:http://www.santabanta.com/wallpapers/gauhar-khan/
请帮我