Smartproxy Mobile Proxies: Web Scraping Guide

Smartproxy is one of the more well known providers in the industry. Their major products include Residential Proxies, Static Residential Proxies, Mobile Proxies, Datacenter Proxies, and Site Unblocker. When using Smartproxy, no matter which proxy you purchase, you can be sure that you're getting a stable, reliable product at a decent price point. Throughout the rest of this article, we'll be testing out Smartproxy's Mobile Proxy offering.

TLDR: How to Integrate Smartproxy Mobile Proxy?

To use Mobile Proxies with Smartproxy, we need an account with a USERNAME and PASSWORD for our proxy connection. Once we've got these, we just need to format them into our
`proxy_url`: `http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000`
This URL allows us to forward all of our requests through the connection. Our code example creates a connection to Smartproxy's Mobile Proxy with the USERNAME and PASSWORD mentioned above. We use these to create our proxy_url. Next, we make a dict object holding our proxies. Within this dict, we configure our http and https protocols to use our proxy_url. Whenever we make HTTP requests, we pass proxies=proxies in as a keyword argument. This tells Python Requests to forward all of our requests through that proxy connection.
import requests
USERNAME = "your-username"PASSWORD = "your-password"proxy_url = f"http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {    "http": proxy_url,    "https": proxy_url}
result = requests.get("https://ip.smartproxy.com/json", proxies=proxies)print(result.text)
  • First, we need to create our connection variables: USERNAME, and PASSWORD.
  • We use these connection variables to create our proxy_url: http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000.
  • We create a dict object, which holds our http and https proxies. We then assign both of them to our proxy_url.
  • We send a GET request to the url using the proxies keyword argument.
  • Once we've received our response, we print it to the terminal.
Similar to many other proxy connections, we connect to these proxies using proxy port integration. This means that all of our requests get forwarded through this connection by default.

Understanding Mobile Proxies

What Are Mobile Proxies?

Mobile proxies are specialized proxy servers that route internet traffic through mobile devices (smartphones, tablets) connected to a mobile network. They use IP addresses assigned by mobile carriers, making the traffic appear as if it's coming from a real mobile user.
  • They use 3G, 4G, or 5G connections, which makes them more trustworthy compared to residential or datacenter proxies.
  • Mobile IPs often change frequently due to the nature of mobile carrier systems (NAT - Network Address Translation), which adds an extra layer of anonymity.
  • Websites and services are less likely to block mobile IPs because they are associated with legitimate mobile users.

Why Are Mobile Proxies Important?

Mobile proxies are important because they provide a unique combination of trustworthiness, anonymity, and accessibility that other proxy types may not offer. They play a critical role in various online operations where security, bypassing restrictions, or maintaining credibility is essential. Here're some of the use cases:
  • Ad Verification: Ensuring that ads appear correctly and are not subject to fraud.
  • Web Scraping: Accessing data from websites that impose strict bans on IPs that don't appear organic.
  • Bypassing Geo-Restrictions: Accessing content restricted to specific regions.
  • Social Media Management: Managing multiple accounts on platforms that limit actions from a single IP.
  • SEO and Marketing Research: Conducting localized keyword research and competitor analysis.

Datacenter vs Premium Proxies

There are basically two types of proxies when we talk about things at the lowest level, Datacenter and Premium. While managed proxies are a great solution, under the hood, they are composed of a combination of Datacenter and Premium proxies. Datacenter proxies get their name because they are hosted indside of an actual datacenter. Premium proxies are made up of both Residential and Mobile proxies. In the next few sections, we'll go over the major differences between Datacenter and Premium proxies. Then, we'll go over the differences that between Residential and Mobile proxies.

Datacenter Proxies

Pros
  • Price: The best thing about Datacenter proxies is the price. When you purchase Datacenter proxies from Smartproxy, you get the option to pay for bandwidth, or to pay per IP address. Their bandwidth plans range in price from $0.60/GB to $0.50/GB. If you go based on IP, your plans range from $0.10 per to $0.09 per IP address.
  • Speed: The performance of Datacenter proxies is virtually unbeatable. When you choose a Datacenter Proxy, you'll get quality hardware with a speedy internet connection.
  • Availability: Datacenters tend to hold warehouses of machines and each machine gets its own IP address. Combine this with the fast, stable internet connection mentioned above, and you'll have one of the most reliable proxy connections on the market.
Cons
  • Blocking: More difficult sites tend to block datacenter IP addresses. They want real people to visit their site. If a request is coming from a datacenter, it is likely some type of bot.
  • Less Geotargeting Support: Datacenters do offer geotargeting support, but it's often limited since there aren't all that many datacenters around the world.
  • Less Anonymity: With a datacenter, we don't show up as a normal user. This makes it much more difficult for us to blend in with normal human traffic.

Premium

Pros
  • Anonymity: With a Premium Proxy, you're given an actual residential or mobile IP address. Alongside that, your request gets forwarded through the device of an actual human user.
  • Better Access: With Premium Proxies, we tend to blend in much better. To the site we're trying to scrape, our traffic looks completely human.
Cons
  • Price: Premium Proxies are far more expensive. With Residential and Mobile proxies from Smartproxy, plans start at $7/GB and $8/GB respectively. Compared to $0.60/GB, these proxies cost more than 10 times their datacenter counterparts.
  • Speed: With Premium Proxies, performance can often be a little lacking. With this type of proxy, you're tied to a real device (often an outdated smartphone or laptop) on a real home network.
Residential proxies are ideal for SERP results, ad verification, social media monitoring/scraping and much more.

Mobile vs Residential Proxies

Now, let's get a better understanding of the two types of Premium Proxies: Residential and Mobile. We'll once again take a look at the pros and cons of both. They share many of the same benefits and they are both lumped into the Premium Proxy category, but there are some key differences to be aware of. This way, you can decide which type of proxy is best for you.

Residential Proxies

Pros
  • Authenticity: With a Residential Proxy, you get a real residential IP address tied to someone's actual house or apartment. Your traffic can't look much more human than this.
  • Geotargeting: With Residential Proxies, we often get much finer control over our geotargeting. Sometimes you can even choose which city you want to show up in!
Cons
  • Relatively Static: ISPs (internet service providers) do rotate IP addresses, but they don't do so very often. Whether your provider rotates weekly, monthly, or even yearly, we need to rotate IP addresses to get past IP blocks. This is the achilles heel of Dedicated Residential Proxy services.
  • Sometimes More Detectable: It's not common practice by any means, but there are some sites that check for a mobile only environment. They do this by examining both your IP address and user-agent string.

Mobile Proxies

Pros
  • Dynamic IP Addresses: When you're on a mobile phone, it's changing IP addresses all the time. When you walk down the street, your phone probably jumps from your home network to cellular data, and then possibly to a public network you've used before. On top of this, when using cellular data, your provider will often rotate IP addresses throughout their entire mobile network.
  • Carrier Network Address Translation: This is quite different from the IP rotation we mentioned above. Some carriers actually keep all their devices connected through the same IP mobile address. This type of privacy actually works quite different from the method mentioned above. Since there are a large number of devices using this IP address at any given time, you blend in with everyone else on the network.
  • Social Media/ Mobile First Platforms: It's now the year 2024 and people rarely use actual computers. Their smartphone provides everything they need. Because of this, many sites (like social media based sites), have adopted a mobile first approach. Mobile proxies make us look far more legitimate on these sites.
Cons
  • Reliability: One of the pros of Mobile Proxies, our IPs are always changing. This is actually also a con. Because of the constant network switching, this can lead to some unreliability with our proxy connection.
  • Price: At Smartproxy, Mobile Proxies start at $8/GB on the Pay As You Go plan. This is more than 10 times the price of their Datacenter offerings and 12.5% more than their standard Residential offerings.

Why Use Smartproxy Mobile Proxies?

Smartproxy gives us a Mobile Proxy connection with a relatively low barrier to entry. Their plans start at $8/GB for the Pay As You Go plan. At their highest tier ($300/month), your bandwidth costs only $6/GB. Their simple pricing, geotargeting support, and reliability offer everyone a good product at a competitive price. Smartproxy Homepage Smartproxy Mobile Proxies give us access to pretty much every site on the web.

Smartproxy Mobile Proxy Pricing

Smartproxy offers two different categories for their Mobile Proxy plans: Self-Service and Enterprise. When you combine these categories, we wind up with a total of 8 pricing plans. Their lowest tier plan, Pay As You Go allows you to purchase bandwidth on an as-need basis at $8/GB. Self-Service
  • From there, the Self-Service plans go down by $0.50/GB with each tier.
  • The highest Self-Service plan comes in at $300/month with a price of $6/GB.
Enterprise
  • Their Enterprise plans begin at $550/month and $5.50/GB.
  • The highest tier comes in at $2,250/month and costs at total of $4.50/GB.
The tables below contain more information about these plans. If you're just looking to try it out, I'd recommend using the Pay As You Go plan. If you wish to use one of their Enterprise products, you'll need to contact their sales department before you can purchase it. Self Service Plans
PlanMonthly PricePrice/GB
Pay As You GoN/A$8.00
2GB$15$7.50
8GB$56$7.00
25GB$162.50$6.50
50GB$300$6.00
Enterprise Plans
PlanMonthly PricePrice/GB
100GB$550$5.50
250GB$1,250$5.00
500GB$2,250$4.50
Generally speaking, when proxy providers offer plans around $2-3 per GB, they are considered cheap. If they offer smaller plans in the $6-8 per GB range, they are more expensive. You can use our Proxy Comparison tool. This tool is built for anybody looking for a proxy provider.

Setting Up Smartproxy Mobile Proxies

Now, let's go through the process of using Smartproxy Mobile Proxies. We'll start with the signup process. Then, we'll walk you through all the way to your first request using your new proxy connection. If you're familiar with proxy setup, you can feel free to skip this step.
  1. First, head on over to Smartproxy. As you can see in the screenshot below, you can create an account using either your email address or your Google account.
Smartproxy Homepage
  1. Once you've got your account, you'll be taken to their dashbaord. On the left side of the page, click Proxies. Then, click the Residential dropdown. Your next two options will be Residential and Mobile. Click Mobile.
Smartproxy Select Proxy
  1. Now, you'll be prompted to choose a mobile plan. Since we're just trying it out, we'll go with Pay As You Go. When you're ready, click Continue to checkout.
Smartproxy Mobile Plans
  1. Next, you'll be prompted to actually purchase your plan.
Smartproxy Purchase Plans
  1. After making your payment, it takes a second to confirm.
Smartproxy Purchase Confirmation
  1. Once your payment's been confirmed, you'll be prompted to setup your new proxy.
Smartproxy Setup
  1. Now, you need to go through and configure your proxy. We're going with almost the default setup. Instead of a Static proxy, we use a Rotating one.
Smartproxy Proxy Configuration
  1. Once you're finished with all that, you can test your proxy with a the command below. Make sure to replace YOUR_USERNAME and YOUR_PASSWORD with your actual username and password.
curl -U "YOUR_USERNAME:YOUR_PASSWORD" -x "gate.smartproxy.com:10001" "https://ip.smartproxy.com/json"
You should receive a response similar to the one below.
{    "browser": {        "name": "",        "version": ""    },    "platform": {        "os": "undefined undefined"    },    "engine": {},    "isp": {        "isp": "Vivo",        "asn": 26599,        "domain": "vivozap.com.br",        "organization": "Vivo"    },    "city": {        "name": "Blumenau",        "code": "SC",        "state": "Santa Catarina",        "time_zone": "America/Sao_Paulo",        "zip_code": "89000",        "latitude": -26.8766,        "longitude": -49.0969    },    "proxy": {        "ip": "177.174.250.237"    },    "country": {        "code": "BR",        "name": "Brazil",        "continent": "South America"    }}

Authentication

Throughout this guide, we're going to use our username and password for authentication. However, it is possible to whitelist your IP address. When you add your IP address to the whitelist, you no longer need to authenticate from that address. All requests will be authenticated based on the IP they come from. First, click the Authentication tab and then click Whitelisted IPs. Smartproxy Add Whitelist Then, it's as simple as clicking the Add IP button. Smartproxy add IP In our TLDR or Setting Up sections, you might have noticed that our requests go through a proxy URL like this:
http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000
  • Our authentication string always goes as follows: http://{USERNAME}:{PASSWORD}.
  • Our actual URL starts with our username.
  • Then, we append it with :, and we append our password to that: {USERNAME}:{PASSWORD}.
NOTE: when utilizing geotargeting or any other custom settings, our username is tacked onto the user- flag. In these cases, it would be user-{USERNAME}:{PASSWORD}.

Basic Request Using Smartproxy Mobile Proxies

You now know that all of our requests get authenticated using our USERNAME and PASSWORD. We also know that our formatted proxy URL looks like this:
http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000
Now let's learn how to use this proxy connection in our code.
  • First, we save our USERNAME and PASSWORD variables.
  • They are then used to create our proxy_url: http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000.
  • We use a dict called proxies to hold our http and https protocols.
  • We assign our proxy_url to both of these protocols.
import requests
USERNAME = "your-username"PASSWORD = "your-password"proxy_url = f"http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {    "http": proxy_url,    "https": proxy_url}
result = requests.get("https://ip.smartproxy.com/json", proxies=proxies)print(result.text)
Here's some sample output from the code above.
{    "browser": {        "name": "",        "version": ""    },    "platform": {        "os": "undefined undefined"    },    "engine": {},    "isp": {        "isp": "Comcast Cable",        "asn": 7922,        "domain": "comcast.net",        "organization": "Comcast Cable"    },    "city": {        "name": "Indianapolis",        "code": "IN",        "state": "Indiana",        "time_zone": "America/Indiana/Indianapolis",        "zip_code": "46236",        "latitude": 39.8685,        "longitude": -85.969    },    "proxy": {        "ip": "73.146.135.168"    },    "country": {        "code": "US",        "name": "United States",        "continent": "North America"    }}
In the JSON above, our code (country code) shows up as US with the name of United States. The organization of the isp field is Comcast Cable. If you navigate to their domain, comcast.net, you'll be redirected to Xfinity. A few years back, Comcast rebranded to Xfinity, and they offer cable, internet, and mobile products.

Country Geotargeting

Country geotargeting is the ability to route your internet traffic through a mobile IP address located in a specific country. This ensures that the traffic appears as though it originates from that country, allowing users to bypass geo-restrictions, perform localized tasks, and access region-specific content. Country geotargeting allows you to simulate being in a specific country, providing an edge in accessing region-specific data, marketing, and research while maintaining high levels of anonymity. Smartproxy gives us access to proxies in over 190 countries. To choose a country, you need to add the country flag to your URL. You will also need to add the user flag to your username. We need to append our country code to the country flag. With support for geotargeting, our URL now looks like this:
http://user-{USERNAME}-country-{COUNTRY}:{PASSWORD}@gate.smartproxy.com:7000
Their list of available countries is available here.
import requests
USERNAME = "your-username"PASSWORD = "your-password"COUNTRY = "IT"
proxy_url = f"http://user-{USERNAME}-country-{COUNTRY}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {    "http": proxy_url,    "https": proxy_url}
result = requests.get("https://ip.smartproxy.com/json", proxies=proxies)print(result.text)
There are really only two changes to this code, our user and country flags. We pass our country code in with the country flag. If you run this code, you should get a response similar to the one below. As you can see, we're showing up in IT (Italy).
{    "browser": {        "name": "",        "version": ""    },    "platform": {        "os": "undefined undefined"    },    "engine": {},    "isp": {        "isp": "Vodafone Italia",        "asn": 30722,        "domain": "vodafone.it",        "organization": "Vodafone Italia"    },    "city": {        "name": "Rimini",        "code": "45",        "state": "Emilia-Romagna",        "time_zone": "Europe/Rome",        "zip_code": "47921",        "latitude": 44.0545,        "longitude": 12.5686    },    "proxy": {        "ip": "5.90.141.72"    },    "country": {        "code": "IT",        "name": "Italy",        "continent": "Europe"    }}

City Geotargeting

City geotargeting allows users to route their internet traffic through mobile IP addresses tied to a specific city, rather than just a country. This provides more granular control over the geographic origin of your online activity, enabling precise targeting and better simulation of user behavior within a specific locality. To use city level geotargeting with Smartproxy Mobile Proxies, we actually need to slightly change our proxy domain and port number. Our URL will now look like this:
http://{USERNAME}:{PASSWORD}@city.smartproxy.com:{PORT}
In the table below, which ports match which cities. While they don't have a ton of cities, they do support quite a few major cities around the world.
Port RangeCity
21001-21049New York
21051-21099Los Angeles
21101-21149Chicago
21151-21199Houston
21201-21249Miami
21251-21299London
21301-21349Berlin
21351-21399Moscow
When we want to target a specific city, we send our requests to the city subdomain. Each supported city has its own set of ports. Take a look at the example below.
import requests
USERNAME = "your-username"PASSWORD = "your-password"PORT = 21051
proxy_url = f"http://{USERNAME}:{PASSWORD}@city.smartproxy.com:{PORT}"
proxies = {    "http": proxy_url,    "https": proxy_url}
result = requests.get("https://ip.smartproxy.com/json", proxies=proxies)print(result.text)
When running this code, you'll get a JSON response similar to the one you see below.
{    "browser": {        "name": "",        "version": ""    },    "platform": {        "os": "undefined undefined"    },    "engine": {},    "isp": {        "isp": "Spectrum",        "asn": 20001,        "domain": "spectrum.com",        "organization": "Spectrum"    },    "city": {        "name": "Los Angeles",        "code": "CA",        "state": "California",        "time_zone": "America/Los_Angeles",        "zip_code": "90044",        "latitude": 33.9555,        "longitude": -118.2863    },    "proxy": {        "ip": "76.32.131.65"    },    "country": {        "code": "US",        "name": "United States",        "continent": "North America"    }}
In the example above, we set our port to 21051. This port is within the Los Angeles range of ports (21051-21099). As you can see in our output from our city field, the name is Los Angeles. In five runs of this code, we showed up in Los Angeles all 5 times. For city level geotargeting, this is extremely reliable. City level geotargeting gives us access to hyper localized content. When you're dealing with local content, you can extract the following types of data at a local level. This allows you to collect and manage your precious data at a much more granular level.
  • Local Ads
  • Local Businesses
  • Local Social Media
  • Local Events

Error Codes

Error codes are a must have when dealing with any kind of error. In case you weren't aware, a status code of 200 tells us that our request was successful. Other error codes, however, can be a little more difficult. Each error code comes with its own message. We use these messages to troubleshoot our errors and hopefully fix them. When you receive an HTTP error, you need to lookup the error code and solve it accordingly.
Status CodeTypeDescription
200SuccessEverything works as expected.
400Bad RequestYour request is likely formatted incorrectly.
401Unauthorized ErrorFailed to authenticate on your target website.
403ForbiddenAccess to this site is forbidden.
404Not FoundDouble check your url, no content was found.
407Proxy Authentication RequiredDouble check your API key.
408Request TimeoutThe requested server timed out, try again.
500Internal Server ErrorThe proxy server had an error, please retry request.
502Invalid ResponseProxy server received an invalid response, retry request.
503Service UnavailableProxy server is currently down or overloaded.
504Gateway TimeoutProxy server timed out waiting for the upstream server.
522Connect TimeoutFailed to connect to the proxy, try again.
525No Exit FoundProxy was unable to find an exit node for the request.
Status codes are imperative. When you encounter an error, you need to look up the status code and troubleshoot accordingly.

KYC Verification

KYC (Know Your Customer) verification is a pretty standard process when using Mobile and Residential Proxies. When you create an account at Smartproxy, they use an ongoing KYC process which includes continuous account monitoring. If they find anything suspicious about your activity, you'll be required to send ID verification to them. They also reserve the right to suspend or ban your account immediately in the event of suspicious or nefarious activity. They use this KYC process to protect their bandwidth providers. These people are providing customers like you with their own internet connection.

Implementing Smartproxy Mobile Proxies in Web Scraping

Now, we understand the basic idea behind using Smartproxy Mobile Proxies. Let's take this new knowledge and apply it to some of our favorite web scraping frameworks. In Python, we'll show some code examples for Reqeusts, SeleniumWire (DEPRECATED), and Scrapy. Then, we'll show you how to do the same thing in NodeJS with Puppeteer and Playwright. By the end of this section, you can get connected to Smartproxy Mobile Proxies easily.

Python Requests

Here, we'll use the basic example you might remember from the TLDR section.
  1. First, we need to create our environment variables. We'll use those variables to create our proxy_url.
  2. Then, we'll create a dict called proxies.
  3. Within proxies, we assign our proxy_url to both the http and https protocols.
  4. Whenever we make an HTTP request, we pass proxies=proxies in as a keyword arguments.
  5. The proxies kwarg tells Python Requests to forward all these requests through our proxy_url.
import requests
USERNAME = "your-username"PASSWORD = "your-password"proxy_url = f"http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {    "http": proxy_url,    "https": proxy_url}
result = requests.get("https://ip.smartproxy.com/json", proxies=proxies)print(result.text)
  • Just like in our previous examples, we setup our configuration variables.
  • Our proxy_url is composed from those variables: http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000.
  • We then create a dict object that holds both our http and https proxies.
  • When making our requests, we make sure to pass proxies=proxies. This tells Python Requests to use the dict object we created for our proxy settings.
  • Once we get our response back, we print it to the terminal.

Python Selenium

Vanilla Selenium does not support authenticated proxies. For many years, SeleniumWire has been the fix for this problem. We're sad to say, however, SeleniumWire has been deprecated. It hasn't received any code updates in two years and will probably never receive them again. However, it is still technically possible to use Smartproxy Mobile Proxies via SeleniumWire, but we strongly advise against it. When you decide to use SeleniumWire, you are vulnerable to the following risks:
  • Security: Browsers are updated with security patches regularly. Without these patches, your browser will have holes in the security that have been fixed in other browsers such as Chromedriver or Geckodriver.
  • Dependency Issues: SeleniumWire is no longer maintained. In time, it will not be able to keep up with its dependencies as they get updated. Broken dependencies can be a source of unending headache for anyone in software development.
  • Compatibility: As the web itself gets updated, SeleniumWire doesn't. Regular browsers are updated all the time. Since SeleniumWire no longer receives updates, you may experience broken functionality and unexpected behavior.
As time goes on, the probability of all these problems increases. If you understand the risks but still wish to use SeleniumWire, you can view a guide on that here. Depending on your time of reading, the code example below may or may not work. As we mentioned above, we strongly recommend against using SeleniumWire because of its deprecation, but if you decide to do so anyway, here you go. We are not responsible for any damage that this may cause to your machine or your privacy. As well, the example below does not contain any retry logic for bad responses. If you wish to do so, you can add this in yourself.
from seleniumwire import webdriverimport json
USERNAME = "your-username"PASSWORD = "your-password"proxy_url = f"http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000"
## Define Your Proxy Endpointsproxy_options = {    "proxy": {        "http": proxy_url,        "https": proxy_url,        "no_proxy": "localhost:127.0.0.1"    }}
## Set Up Selenium Chrome driverdriver = webdriver.Chrome(seleniumwire_options=proxy_options)
## Send Request Using Proxydriver.get('https://httpbin.org/ip')
  • We build our proxy_url using our config variables, just like we did in earlier examples.
  • We assign this url to both the http and https protocols of our proxy settings.
  • driver = webdriver.Chrome(seleniumwire_options=proxy_options) tells webdriver to open Chrome with our custom seleniumwire_options.

Python Scrapy

Time to do the same thing using Scrapy. We'll code our proxy connection into our spider file. Once we've written the connection, we simply use request.meta['proxy'] = proxy_url to tell Scrapy to use our proxy. To start, we need to make a new Scrapy project.
scrapy startproject mobile
Then, from within your new Scrapy project, create a new Python file inside the spiders folder with the following code.
import scrapy
USERNAME = "your-username"PASSWORD = "your-password"proxy_url = f"http://{USERNAME}:{PASSWORD}@gate.smartproxy.com:7000"

class ExampleSpider(scrapy.Spider):    name = "mobile_proxy"
    def start_requests(self):        request = scrapy.Request(url="https://httpbin.org/ip", callback=self.parse)        request.meta['proxy'] = proxy_url        yield request
    def parse(self, response):        print(response.body)
You can run this spider with the following command.
scrapy crawl mobile_proxy
  • As always, we create our configuration variables.
  • Once again, we use these config variables to create our proxy_url.
  • From inside of start_requests, we use proxy_url = request.meta['proxy']. This tells Scrapy that all of our requests should go through the proxy we created.

NodeJS Puppeteer

Connecting to our proxy with NodeJS Puppeteer is a bit different from our previous examples. Puppeteer has builtin support for authentication. With Puppeteer, we get a special place for both our username and password. Create a new folder.
mkdir puppeteer-mobile
cd into the new folder and create a new JavaScript project.
cd puppeteer-mobilenpm init --y
Next, we need to install Puppeteer.
npm install puppeteer
Next, create a new JavaScript file. Copy and Paste the code below into your new file. Make sure to move or copy your proxy list into your new project folder.
const puppeteer = require("puppeteer");
const USERNAME = "your-username";const PASSWORD = "your-password";const proxyUrl = "gate.smartproxy.com:7000";
(async () => {  const browser = await puppeteer.launch({    args: [`--proxy-server=http://${proxyUrl}`]  });
  const page = await browser.newPage();
  await page.authenticate({    username: USERNAME,    password: PASSWORD  });
  await page.goto('http://lumtest.com/myip.json');  await page.screenshot({path: 'puppeteer.png'});
  await browser.close();})();
  • First, we create our config variables: USERNAME, and PASSWORD. We declare all of them using the const keyword.
  • We add our proxy url to our proxy-args: args: [`--proxy-server=http://${proxy_url}`].
  • We pass the following credentials into page.authenticate():
    • username: USERNAME
    • password: PASSWORD
Compared to the Python frameworks above, Puppeteer gives us first class support for our Mobile Proxy. USERNAME and PASSWORD get passed straight into page.authenticate() to set up our proxy. The screenshot below came from running our Puppeteer code above. Puppeteer Proxy Results

NodeJS Playwright

Connecting to Playwright is going to very similar to Puppeteer. Puppeteer and Playwright actually share a common origin coming from Chrome's DevTools. If you look at the code example below, Playwright also has designated spots for our USERNAME and PASSWORD. Follow the steps below to get up and running quickly. Create a new project folder.
mkdir playwright-mobile
cd into the new folder and initialize a JavaScript project.
cd playwright-mobilenpm init --y
Install Playwright.
npm install playwrightnpx playwright install
Next, you can copy/paste the code below into a JavaScript file. Once again, make sure to add your proxy list to your project folder.
const playwright = require("playwright");
const USERNAME = "your-username";const PASSWORD = "your-password";const proxyUrl = "gate.smartproxy.com:7000";
const options = {    proxy: {        server: proxyUrl,        username: USERNAME,        password: PASSWORD    }};
(async () => {    const browser = await playwright.chromium.launch(options);    const page = await browser.newPage();
    await page.goto('http://lumtest.com/myip.json');
    await page.screenshot({ path: "playwright.png" })
    await browser.close();})();
  • Just like with Puppeteer, we first setup our configuration variables.
  • We create a proxy object with the following fields:
  • server: http://${proxy_url}
  • username: FULL_USER
  • password: PASSWORD
  • Instead of using page.authenticate(), with Playwright, we pass our options into chromium.launch().
Like Puppeteer, Playwright gives us first class proxy support. You can view an example response in the screenshot below. Playwright Proxy Results

Case Study: Scrape Weather.com

It's time to do a small case study. Now, we're going to scrape a small amount of metadata from weather.com. We only need to scrape the site description.
  • First, we'll perform this scrape with a Portuguese mobile proxy.
  • Then, we'll repeat the process with a mobile proxy in the US.
This case study is going to teach us a couple things.
  1. Weather is different all over the world.
  2. Weather.com should give us different content based on our location.
With mobile proxies, sometimes it takes a couple tries to get a proper response. This can be due to connectivity issues. We'll count how many tries it takes to get a successful response using each proxy. This will allow us to benchmark the proxy quality in each country. Ideally, both proxies should get our content on the first try, but that isn't always the case. Here is our case study code.
  1. We start by using urllib3 to disable some SSL warnings and make it easier to read our output.
  2. As we talked about above, we setup our first proxy connection in Portugal.
  3. With our Portuguese proxy, we scrape the site description. We also count the amount of tries it takes for a successful response.
  4. Afterward, we perform the same scrape using a US based proxy. This allows us to compare the quality of both proxy connections.
import requestsimport urllib3from bs4 import BeautifulSoup
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
USERNAME = "your-username"PASSWORD = "your-password"COUNTRY = "PT"
proxy_url = f"http://user-{USERNAME}-country-{COUNTRY}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {  "http": proxy_url,  "https": proxy_url}
headers = {    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"}
print("----------------------PT-------------------")
success = False
tries = 1while not success:    response = requests.get("https://weather.com", proxies=proxies, headers=headers, verify=False)    if response.status_code != 200:        print(f"Failed to get site, Status Code: {response.status_code}")        tries+=1        continue
    soup = BeautifulSoup(response.text, "html.parser")    description_tag = soup.select_one("meta[name='description']")    description = description_tag.get("content")
    print("Description:", description)    print("Total tries:", tries)    success = True

print("----------------------US---------------------")
COUNTRY = "US"
proxy_url = f"http://user-{USERNAME}-country-{COUNTRY}:{PASSWORD}@gate.smartproxy.com:7000"
proxies = {  "http": proxy_url,  "https": proxy_url}
success = Falsetries = 1while not success:    response = requests.get("https://weather.com", proxies=proxies, headers=headers, verify=False)    if response.status_code != 200:        print(f"Failed to get site, Status Code: {response.status_code}")        tries+=1        continue
    soup = BeautifulSoup(response.text, "html.parser")    description_tag = soup.select_one("meta[name='description']")    description = description_tag.get("content")
    print("Description:", description)    print("Total tries", tries)    success = True
Here are some key things you should notice in this code:
  • urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) is used to disable our SSL warnings. When using a proxy port, SSL errors can be common and the pollute the output we're trying to read.
  • After setting up each proxy connection, we do the following:
  • Then, we create our success and tries variables.
  • For each attempt, we use a while loop. After each attempt, we increment our tries. Once we get a successful response, we set success to True and this allows us to exit the loop.
  • We locate the page description with soup.select_one("meta[name='description']").
  • We finally print our tries and description to the terminal.
If you run this code, you shuuld receive something similar to this.
----------------------PT------------------- Description: Previsão e condições meteorológicas e radar Doppler de hoje e de hoje à noite para Socorro, Lisboa por The Weather Channel e Weather.com Total tries: 1 ----------------------US--------------------- Description: The Weather Channel and weather.com provide a national and local weather forecast for cities, as well as weather radar, report and hurricane coverage Total tries 1
Take a look at our site descriptions for each proxy.
  • Portugal: Previsão e condições meteorológicas e radar Doppler de hoje e de hoje à noite para Socorro, Lisboa por The Weather Channel e Weather.com.
  • United States: The Weather Channel and weather.com provide a national and local weather forecast for cities, as well as weather radar, report and hurricane coverage.
Now, take a look at our total tries for each proxy.
  • Portugal: 1
  • United States: 1
Both of our proxies were able to get the content on the first try. We ran this code 5 times to make sure. On each run, we received our response on the first try. With some mobile proxy providers, we tend to get errors or inconsistent connections more often than that. We can conclude that, Smartproxy offers a steady, reliable mobile connection regardless of your location.

Alternative: ScrapeOps Residential Proxy Aggregator

Smartproxy Mobile Proxies are great, but they can be kind of expensive. ScrapeOps offers a Residential Proxy Aggregator which also gives you mobile proxy access at an even better price. With our Residential Proxy Aggregator, you get the same anonymity and anti-bot resistance that you get from Smartproxy Mobile Proxies. ScrapeOps Residential Proxy Aggregator provides access to the top 20 residential proxy providers through a single port, ensuring a high success rate for web scraping tasks. It automatically switches proxies to avoid blocks, optimizing performance and cost with flexible pricing plans.
  • Access to the top 20 residential proxy providers, including Smartproxy, Bright Data, and Oxylabs.
  • 98% success rate due to automatic proxy switching.
  • Bypasses anti-bot measures and avoids blocks.
  • Optimizes performance and cost by monitoring proxy performance and pricing.
  • Flexible pricing plans starting at $15 per month, with up to $999 for higher usage.
  • 500 MB of free bandwidth credits to start. Our plans range in price from free (yes... FREE) all the way to $999 per month. We have 8 different choices available.
The table below outlines our pricing.
Monthly PriceBandwidthPrice per GB
Free100MB$0
$153GB$5
$4510GB$4.50
$9925GB$3.96
$14950GB$2.98
$249100GB$2.49
$449200GB$2.25
$999500GB$2
With us, you get access to Smartproxy and many other providers. You can start your free trial here. It comes with 500MB of free bandwidth. Once you've got your free trial, you can copy and paste the code below to check your proxy connection.
import requestsfrom urllib.parse import urlencode
API_KEY = "your-super-secret-api-key"
proxy_url = f"http://scrapeops.mobile=true:{API_KEY}@residential-proxy.scrapeops.io:8181"
proxies = {    "http": proxy_url,    "https": proxy_url}
response = requests.get("https://lumtest.com/myip.json", proxies=proxies, verify=False)print(response.text)
In the code above, we do the following.
  • With ScrapeOps, we only need our API_KEY.
  • We use our API_KEY to build our proxy_url: http://scrapeops.mobile=true:{API_KEY}@residential-proxy.scrapeops.io:8181.
  • The flag, mobile=true, tells ScrapeOps that we want a mobile IP address.
  • We check our IP information by making a GET: requests.get("https://lumtest.com/myip.json", proxies=proxies, verify=False).
  • Finally, we print it to the terminal. You should get an output similar to what you see below. We removed the SSL warning to make the output more legible.
{"country":"KH","asn":{"asnum":17976,"org_name":"CAMGSM Company Ltd"},"geo":{"city":"Phnom Penh","region":"12","region_name":"Phnom Penh","postal_code":"","latitude":11.5583,"longitude":104.9121,"tz":"Asia/Phnom_Penh","lum_city":"phnompenh","lum_region":"12"}}
Take a look the org_name of our proxy connection, CAMGSM Company Ltd. According to Wikipedia, CAMGSM Company Ltd is a telecommunications provider. If you Google them, they show up as a mobile provider. We're getting mobile results when passing in the mobile flag. Our mobile bandwidth comes in at a far better price with a low tier paid plan of $5/GB and a top tier plan of $2/GB. Compared to Smartproxy, ScrapeOps is practically a steal!
Smartproxy prides itself on using only ethically sourced proxies. As we mentioned earlier, they use an ongoing KYC process for all of their customers. The screenshot below actually comes from their landing page. They talk about this on their website here. Smartproxy Ethics When mobile and residential proxies are sourced, they come from real people using real devices on their personal internet connection. Ethical sourcing of residential proxies means that everyone providing bandwidth knows they're providing bandwidth. When we use datacenter proxies, they come from a datacenter, there is no way that our proxy could come from a user unknowingly running software on their smartphone. Don't ever break laws using a proxy provider. As you already know, it's illegal. It also harms everyone involved. It harms the proxy provider. It eventually harms you too. When you break the law with a proxy, it gets traced to the proxy provider. Your provider will trace it to your account using either your API key or your username and password. This creates problems for both you and your proxy service.
  • Don't use proxies to access illegal content: This can bring you legal fines or even jail time depending on what you're trying to access.
  • Don't scrape and disseminate other people's private data: It varies by jurisdiction, but this is also a highly illegal and dangerous practice. Doxxing private data can lead to heavy fines and/or possibly jail/prison time.

Ethical

Laws aren't the only thing we should think about when scraping the web. We need to think about right and wrong. There are many things that are morally wrong, but still completely legal. Nobody wants to be in the next headline about ethically questionable data harvesting. This sort of reputational damage can completely destroy a company.
  • Social Media Monitoring: Social media stalking can be a very destructive and disrespectful behavior. How would you feel if someone used data collection methods on your account?
  • Respect Site Policies: Failure to respect a site's policies can get your account suspended/banned. It can even lead to legal troubles for those of you who sign and violate a terms of service agreement.

Conclusion

When we use Smartproxy Mobile Proxies, we get a reliable and stable connection with some of the additional perks of using a Mobile IP address. You should understand that there's a tool for every job. Datacenter proxies can't access everything, and Mobile Proxies are an excellent fallback. When we use Smartproxy Mobile Proxies, we get all the benefits of a Residential Proxy and more! By this point, you should also understand how to use Smartproxy Mobile Proxies with Python Requests, Scrapy, NodeJS Puppeteer and NodeJS Playwright. You can view the full documentation for Smartproxy Mobile Proxies here.

More Cool Articles

Go ahead, keep reading! We have a ton of content that you can learn from here at ScrapeOps. Whether you're a seasoned dev or your brand new to web scraping, we've got something useful for you. We love scraping so much that we wrote the Python Web Scraping Playbook. If you want to learn more, take a look at the articles below.