import requests
import sys
from bs4 import BeautifulSoup
reload(sys)
sys.setdefaultencoding('utf-8')
type = sys.getfilesystemencoding()
s = requests.session()
s.proxies = {
'http' : '149.56.206.48:8080'}
url = 'https://facebook.com'
header = {
'User-Agent' : 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36', }
response = s.get(url,headers = header,verify=False)
f = open('FC.txt','w')
f.write(response.content)
f.close()
爬不了facebook的信息,会不会是代理的问题啊
requests 的代理,http 和 https
要分别设置。
s.proxies = { 'http' : '149.56.206.48:8080', 'https' : 'xxx.xxx.xxx.xxx:nn' # https代理服务器 }
我只找到了http的代理,但是应该只是提醒,不是这个错误啊,这个错误不是这个问题吧
@nonomo
免费高速HTTP代理IP列表(2016-11-03) IP PORT 匿名度 类型 get/post支持 123.158.163.111 8888 匿名 HTTP, HTTPS GET, POST
s.proxies = { 'http' : '123.158.163.111:8888', 'https' : '123.158.163.111:8888' # https代理服务器 }
这不是可以吗?好像需要模拟登录才行,不登录只能显示这个页面
还有以后提问问题一定要排版好才发出来,你这样子的代码很难看的,