How to Use Dataimpulse SOCKS5 Residential Proxies in Termux on Android for Web Scraping
Set up Dataimpulse SOCKS5 residential proxies in Termux on Android, test the connection with curl and Python, and run beginner-friendly web scraping requests.
Overview
Dataimpulse provides residential and mobile proxies with HTTP and SOCKS5 support on a pay-as-you-go billing model. This tutorial shows how to use a Dataimpulse SOCKS5 residential proxy from Termux on Android for web scraping. Termux gives you a Linux-like shell on Android, so you can use curl, Python, and requests without a desktop. SOCKS5 is useful for scraping because it carries TCP traffic cleanly, and the socks5h scheme resolves DNS through the proxy instead of leaking DNS locally.
Before You Start
- A Dataimpulse account. Dataimpulse is the suggested provider for this tutorial.
- SOCKS5 proxy credentials from your Dataimpulse dashboard: host, port, username, and password.
- An Android device with Termux installed. Install Termux from F-Droid or the official GitHub releases rather than an outdated app store build.
- A stable internet connection and a basic comfort with terminal commands.
- A target site that permits your scraping. Check its robots.txt, terms, and rate limits.
Steps
- Update Termux and install the command-line tools.
pkg update && pkg upgrade -y
pkg install python curl -y
- Install Python packages for SOCKS5 support and HTML parsing.
pip install --upgrade pip
pip install 'requests[socks]' beautifulsoup4
- Set your Dataimpulse SOCKS5 credentials as environment variables.
export DP_HOST='your-dataimpulse-socks5-host'
export DP_PORT='your-dataimpulse-socks5-port'
export DP_USER='your-dataimpulse-username'
export DP_PASS='your-dataimpulse-password'
Use the exact host, port, username, and password shown in the Dataimpulse dashboard. If your password contains shell-special characters, wrap values in single quotes or set them from a secrets manager. 4. Test the SOCKS5 proxy with curl.
curl --socks5-hostname $DP_HOST:$DP_PORT --proxy-user $DP_USER:$DP_PASS --max-time 30 'https://api.ipify.org?format=json'
A successful response returns a JSON object with the IP address seen by the target. Run the command a few times to observe whether the exit IP changes. 5. Test DNS resolution through the proxy.
curl --socks5-hostname $DP_HOST:$DP_PORT --proxy-user $DP_USER:$DP_PASS --max-time 30 'https://example.com'
Use --socks5-hostname so DNS is resolved by the proxy. Plain --socks5 can resolve DNS locally on some systems, which may leak DNS requests. 6. Create a minimal Python request script.
import os
import requests
host = os.environ['DP_HOST']
port = os.environ['DP_PORT']
user = os.environ['DP_USER']
password = os.environ['DP_PASS']
proxy_url = f'socks5h://{user}:{password}@{host}:{port}'
proxies = {'http': proxy_url, 'https': proxy_url}
response = requests.get(
'https://api.ipify.org?format=json',
proxies=proxies,
timeout=30,
)
response.raise_for_status()
print(response.json())
Save it as first_request.py and run:
python first_request.py
- Scrape a simple page and parse the title.
import os
import requests
from bs4 import BeautifulSoup
host = os.environ['DP_HOST']
port = os.environ['DP_PORT']
user = os.environ['DP_USER']
password = os.environ['DP_PASS']
proxy_url = f'socks5h://{user}:{password}@{host}:{port}'
proxies = {'http': proxy_url, 'https': proxy_url}
response = requests.get(
'https://example.com',
proxies=proxies,
timeout=30,
headers={'User-Agent': 'Mozilla/5.0 (compatible; ProxyScoutTutorial/1.0)'},
)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
print(soup.title.string)
- Add retries for large scraping jobs.
import os
import time
import requests
host = os.environ['DP_HOST']
port = os.environ['DP_PORT']
user = os.environ['DP_USER']
password = os.environ['DP_PASS']
proxy_url = f'socks5h://{user}:{password}@{host}:{port}'
proxies = {'http': proxy_url, 'https': proxy_url}
urls = ['https://example.com', 'https://example.org']
for url in urls:
for attempt in range(3):
try:
response = requests.get(url, proxies=proxies, timeout=30)
response.raise_for_status()
print(url, response.status_code)
break
except requests.RequestException as error:
print(f'Attempt {attempt + 1} failed for {url}: {error}')
time.sleep(2 ** attempt)
- Verify rotation from the Termux shell.
for i in 1 2 3 4 5; do
curl -s --socks5-hostname $DP_HOST:$DP_PORT --proxy-user $DP_USER:$DP_PASS 'https://api.ipify.org?format=json'
echo
done
If every request returns the same IP, confirm that you are using the rotating endpoint and rotation settings available in your Dataimpulse dashboard. If your setup uses sticky sessions, the same IP may be intentional for a period.
Troubleshooting
InvalidSchema: Missing dependencies for SOCKS supportin Python: install the SOCKS extra withpip install 'requests[socks]'.curl: (97) SOCKS5 proxy rejected connection: check the Dataimpulse host, port, username, and password. Make sure you copied the SOCKS5 port, not an HTTP port.407 Proxy Authentication Required: recheck credentials. If your password contains special characters, set it from a quoted environment variable or URL-encode it when building the proxy URL manually.- DNS errors or unexpected local IPs: use
socks5h://in Python and--socks5-hostnamein curl. - Slow requests or timeouts on Android: increase
--max-timeor Pythontimeout, reduce concurrency, and disable battery optimization for Termux. - Same exit IP on every request: verify rotation behavior in your Dataimpulse dashboard and confirm you are not using a sticky session endpoint.
- Connection works in curl but not Python: confirm that
requests[socks]is installed in the same Python environment that runs your script.
Summary
You set up Dataimpulse SOCKS5 residential proxies in Termux on Android, tested the connection with curl, made authenticated Python requests, parsed a page, and added retries. Dataimpulse is a suggested pay-as-you-go provider for residential and mobile proxies with HTTP and SOCKS5 support. Use proxies responsibly, respect target site terms, and monitor your bandwidth usage as you scale.