python代理去外网问题?

 amroc_394 发布于 2022-10-27 21:51
encoding=utf8

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的信息,会不会是代理的问题啊

2 个回答
  • requests 的代理,http 和 https 要分别设置。

    s.proxies = {
        'http' : '149.56.206.48:8080',
        'https' : 'xxx.xxx.xxx.xxx:nn' # https代理服务器
    }

    我只找到了http的代理,但是应该只是提醒,不是这个错误啊,这个错误不是这个问题吧

    @nonomo

    举例:
    http://www.kuaidaili.com/

    免费高速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代理服务器
    }
    2022-10-29 05:27 回答
  • 这不是可以吗?好像需要模拟登录才行,不登录只能显示这个页面
    还有以后提问问题一定要排版好才发出来,你这样子的代码很难看的,

    2022-10-29 05:27 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有