Python Hacking Tools - Web Scraper

本文介绍如何使用Python的Requests和BeautifulSoup库从免费代理网站抓取代理列表。通过安装必要的库并编写简单的Python脚本,可以自动获取代理服务器的IP地址和端口。此教程适合初学者了解Python网络爬虫的基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Preparation:

Python Libray in the following programming:

1. Requests Document: https://2.python-requests.org//en/master/

2. Beautiful Soup Documentation: https://www.crummy.com/software/BeautifulSoup/bs4/doc/

Install the lib on Kali Linux:

apt-get install python-requests

apt-get install python-bs4

Proxy Domain:

https://free-proxy-list.net/

https://free-proxy-list.com/

 

 

 Python Scraper Code:

import requests
from bs4 import BeautifulSoup

proxyDomain = "https://free-proxy-list.com/"

r = requests.get(proxyDomain,headers={"User-Agent": "XY"})

soup = BeautifulSoup(r.content, 'html.parser')

table = soup.find('table', {"class" : "table table-striped proxy-list"})

for row in table.find_all('tr'):
    columns = row.find_all('td')
    try:
        print "%s:%s\t%-20s\t%-10s" %(columns[0].get_text(),columns[1].get_text().strip(),columns[2].get_text().strip(),columns[3].get_text().strip())
    except:
        pass

 

Execute Result:

转载于:https://www.cnblogs.com/keepmoving1113/p/11312429.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值