<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kurnia Sari</title>
    <description>The latest articles on DEV Community by Kurnia Sari (@kurnia_sari).</description>
    <link>https://dev.to/kurnia_sari</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2939080%2F5e13175d-9c13-4fe6-a127-2ef09b8d3cd7.jpeg</url>
      <title>DEV Community: Kurnia Sari</title>
      <link>https://dev.to/kurnia_sari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kurnia_sari"/>
    <language>en</language>
    <item>
      <title>Detecting and Avoiding Proxy Blacklists When Scraping</title>
      <dc:creator>Kurnia Sari</dc:creator>
      <pubDate>Thu, 13 Mar 2025 10:03:47 +0000</pubDate>
      <link>https://dev.to/kurnia_sari/detecting-and-avoiding-proxy-blacklists-when-scraping-1p27</link>
      <guid>https://dev.to/kurnia_sari/detecting-and-avoiding-proxy-blacklists-when-scraping-1p27</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojtj9pl134c46cdydmqn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojtj9pl134c46cdydmqn.jpg" alt="Image description" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When web scraping, proxies can get blacklisted if a website detects suspicious activity. Detecting and avoiding proxy blacklists ensures uninterrupted access and reduces the risk of getting blocked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Case: Preventing IP Blacklisting While Scraping E-commerce Prices
&lt;/h2&gt;

&lt;p&gt;An e-commerce intelligence firm scrapes competitor pricing data daily. Their proxies risk being blacklisted due to frequent requests. By monitoring for blacklists and rotating proxies, they maintain seamless data collection.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Detect if a Proxy is Blacklisted
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Check HTTP Response Codes
&lt;/h3&gt;

&lt;p&gt;Certain HTTP status codes indicate blacklisting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;403 Forbidden – The IP is blocked from accessing the site.&lt;/li&gt;
&lt;li&gt;429 Too Many Requests – The site has rate-limited the IP.&lt;/li&gt;
&lt;li&gt;503 Service Unavailable – Temporary or permanent block due to bot detection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example: Checking HTTP Status Codes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
proxy = {"http": "http://proxy-provider.com:port", "https": "http://proxy-provider.com:port"}
url = "https://example.com"

response = requests.get(url, proxies=proxy)
print(response.status_code)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Monitor for CAPTCHA Challenges
&lt;/h3&gt;

&lt;p&gt;If a website consistently serves CAPTCHA challenges, the proxy is likely flagged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Detecting CAPTCHA&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from bs4 import BeautifulSoup

soup = BeautifulSoup(response.text, "html.parser")
if soup.find("div", {"class": "captcha"}):
    print("CAPTCHA detected. Proxy may be blacklisted.")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Use an IP Blacklist Checker
&lt;/h3&gt;

&lt;p&gt;Check if your proxy IP is blacklisted using services like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spamhaus&lt;/li&gt;
&lt;li&gt;IPVoid&lt;/li&gt;
&lt;li&gt;WhatIsMyIP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example: Using an API to Check Blacklists&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some services offer APIs to check if an IP is blacklisted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests

api_url = "https://api.blacklistchecker.com/check?ip=your_proxy_ip"
response = requests.get(api_url)
print(response.json())

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to Avoid Proxy Blacklisting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Rotate Proxies Automatically
&lt;/h3&gt;

&lt;p&gt;Using a proxy rotation service ensures your IPs do not get flagged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Rotating Proxies in Python&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import random

proxies = [
    "http://proxy1:port",
    "http://proxy2:port",
    "http://proxy3:port"
]

proxy = {"http": random.choice(proxies), "https": random.choice(proxies)}
response = requests.get(url, proxies=proxy)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Use Residential or Mobile Proxies
&lt;/h3&gt;

&lt;p&gt;Residential and mobile proxies are harder to detect compared to datacenter proxies.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Implement User-Agent and Header Spoofing
&lt;/h3&gt;

&lt;p&gt;Randomizing request headers helps avoid detection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Spoofing User-Agent&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
}
response = requests.get(url, headers=headers, proxies=proxy)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Introduce Random Delays Between Requests
&lt;/h3&gt;

&lt;p&gt;Adding random delays prevents triggering rate limits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import time
import random

time.sleep(random.uniform(1, 5))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Use CAPTCHA-Solving Services
&lt;/h3&gt;

&lt;p&gt;If a site presents CAPTCHAs, integrating a solver like 2Captcha or Anti-Captcha can help.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Detecting and avoiding proxy blacklists is crucial for effective web scraping. By monitoring HTTP responses, using blacklist checkers, and implementing proxy rotation, scrapers can maintain uninterrupted access.&lt;/p&gt;

&lt;p&gt;For an automated and AI-powered solution, consider &lt;a href="https://mrscraper.com/" rel="noopener noreferrer"&gt;Mrscraper&lt;/a&gt;, which manages proxy rotation, evasion techniques, and CAPTCHA-solving for seamless scraping.&lt;/p&gt;

</description>
      <category>webscraping</category>
      <category>proxy</category>
      <category>programming</category>
      <category>mrscraper</category>
    </item>
  </channel>
</rss>
