Using a proxy for web scraping helps you avoid IP bans, rate limits, and geographic restrictions. Here’s a step-by-step guide on how to integrate a proxy into your scraping workflow.
1. Choose a Proxy Type
For web scraping, you can use:
- Datacenter Proxies – Fast but easily blocked.
- Residential Proxies – Harder to detect but slower.
- Mobile Proxies (Best for Scraping) – Rotating IPs, high anonymity, and less likely to be blocked.
Since you're using
Bulgarian mobile proxies, you get:
High anonymity (IPs appear as real mobile users)
Rotating IPs (changes frequently to avoid detection)
Bypass restrictions (great for scraping sites with strong security)
2. Set Up the Proxy in Your Scraper
Most scrapers support proxy integration. Here’s how you can configure it.
Python with Requests
import requests<br><br>proxy = {<br> "http": "http://username

assword@proxy_address

ort",<br> "https": "http://username

assword@proxy_address

ort"<br>}<br><br>url = "
https://example.com"<br><br>response = requests.get(url, proxies=proxy)<br>print(response.text)<br>
Python with Scrapy
In settings.py:
PROXY = "http://username

assword@proxy_address

ort"<br><br>DOWNLOADER_MIDDLEWARES = {<br> 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 1,<br> 'scrapy.downloadermiddlewares.retry.RetryMiddleware': 90,<br>}<br><br>HTTP_PROXY = PROXY<br><br>class ProxyMiddleware:<br> def process_request(self, request, spider):<br> request.meta['proxy'] = HTTP_PROXY<br>
Selenium with Proxy
from selenium import webdriver<br>from selenium.webdriver.chrome.options import Options<br><br>proxy = "username

assword@proxy_address

ort"<br><br>chrome_options = Options()<br>chrome_options.add_argument(f'--proxy-server=http://{proxy}')<br><br>driver = webdriver.Chrome(options=chrome_options)<br>driver.get("
https://example.com")<br>print(driver.page_source)<br>driver.quit()<br>
3. Rotate Proxies to Avoid Bans
If your proxy supports
IP rotation, it will change automatically. Otherwise, you can:
- Use multiple proxies and switch randomly.
- Set delays between requests.
- Implement user-agent rotation.
Random Proxy Rotation Example
import random<br><br>proxies = [<br> "http://user

ass@proxy1

ort",<br> "http://user

ass@proxy2

ort",<br> "http://user

ass@proxy3

ort",<br>]<br><br>proxy = {"http": random.choice(proxies), "https": random.choice(proxies)}<br>response = requests.get("
https://example.com", proxies=proxy)<br>
4. Handle Captchas & Blocks
If the target site is blocking your scraper:
- Use Headless Browsing (Selenium, Puppeteer)
- Implement CAPTCHA Solving (2Captcha, Anti-Captcha)
- Mimic Human Behavior (Random delays, scrolling, mouse movements)
Example with
2Captcha:
import requests<br><br>API_KEY = "your_2captcha_api_key"<br>site_key = "sitekey_from_target_page"<br>url = "
https://example.com"<br><br>response = requests.post("
http://2captcha.com/in.php", data={<br> "key": API_KEY,<br> "method": "userrecaptcha",<br> "googlekey": site_key,<br> "pageurl": url<br>})<br><br>captcha_id = response.text.split("|")[1]<br>captcha_solution = requests.get(f"
http://2captcha.com/res.php?key={API_KEY}&action=get&id={captcha_id}").text<br><br>print("Captcha Solved:", captcha_solution)<br>
5. Best Practices for Scraping with Proxies
Use rotating proxies to avoid bans
Limit request rate (e.g., 1 request per second)
Use real user-agents and headers
Respect website rules (Check robots.txt)
Use headless browsers for JavaScript-heavy sites
By following these steps, you can scrape efficiently using your
Bulgarian mobile proxies without getting blocked.