爬虫系列,(1),ip代理抓取 python

import requests
from bs4 import BeautifulSoup
# 目标地址和头
# 得到的都是墙外的ip,问题就是要想登录目标地址必须先出去
url = 'https://www.sslproxies.org/'
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}

# 获取数据
def get_raw_data(url, headers):
    response = requests.get(url, headers=headers)
    raw_data = response.content.decode()
    return raw_data

# 利用beautifulsoup处理
def bs_data(raw_data):
    soup = BeautifulSoup(raw_data, features='lxml')
    return soup

# 提取IP及其地址信息,返回列表
def bs_extract_ip(soup):
    ip_data = soup.find_all('td', class_='', colspan='')
    ip_list = []

    for i in range(0, 400, 4):
        ip_raw = ip_data[i].contents[0]
        ip_port = ip_data[i+1].contents[0]
        ip_address = ip_data[i+2].contents[0]
        ip_feature = ip_data[i+3].contents[0]
        ip_proxy = '{}:{}'.format(ip_raw, ip_port)
        proxies = "{
  
  {'http': 'http://{ip_input}', 'https': 'https://{
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值