Building a Simple Proxy Rotator with Python and Beautiful Soup

# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
url='https://sslproxies.org/'header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
}
response=requests.get(url,headers=header)
#print(response.content)
for item in soup.select('#proxylisttable tr'):
try:
proxies.append({'ip': item.select('td')[0].get_text(), 'port': item.select('td')[1].get_text()})
except:
print('')
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
from random import randrange
proxies = []def LoadUpProxies(): url='https://sslproxies.org/' header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
}
response=requests.get(url,headers=header)
soup=BeautifulSoup(response.content, 'lxml')
for item in soup.select('#proxylisttable tr'):
try:
proxies.append({'ip': item.select('td')[0].get_text(), 'port': item.select('td')[1].get_text()})
except:
print('')
LoadUpProxies()
print(proxies)
from random import randrange
randrange(10)
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
from random import randrange
proxies = []def LoadUpProxies(): url='https://sslproxies.org/' header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
}
response=requests.get(url,headers=header)
soup=BeautifulSoup(response.content, 'lxml')
for item in soup.select('#proxylisttable tr'):
try:
proxies.append({'ip': item.select('td')[0].get_text(), 'port': item.select('td')[1].get_text()})
except:
print('')
LoadUpProxies()
rnd=randrange(len(proxies))
randomIP=proxies[rnd]['ip']
randomPort=proxies[rnd]['port']
print(randomIP)
print(randomPort)
  • With millions of high speed rotating proxies located all over the world
  • With our automatic IP rotation
  • With our automatic User-Agent-String rotation (which simulates requests from different, valid web browsers and web browser versions)
  • With our automatic CAPTCHA solving technology
curl "http://api.proxiesapi.com/?key=API_KEY&url=https://example.com"

--

--

--

Founder @ ProxiesAPI.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Install Java on Windows 10 Linux subsystem

COVID-19 time and Alexa Skill, part I

Tutorial: Rotating Service Account Keys using Secret Manager

Leetcode — Subarray Sum Equals K

Bootstrap for Beginners

3 Tips for being productive with terminal

AWS was down again; most likely Slack, Zoom and Notion was affected. Why sink with it?

Implementing Merkle Tree and Patricia Trie

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohan Ganesan

Mohan Ganesan

Founder @ ProxiesAPI.com

More from Medium

Retrieve Data from Twitter API and Explore Visualizations in Python

Scraping Profile from LinkedIn using Selenium and Python

Web Scraping Using Scrapy and Regular Expressions in Python

Web scraping basics with python