Get a Page Like a Mobile User
Some sites will serve different content to mobile and desktop users, like Wikipedia.
It redirects mobile users to
That might prove helpful in some scraping scenarios, such as targeted content or faster response due to fewer resources. Whatever reason you have to scrape as a mobile user, two main things matter: window size and user agent (suggested with other headers). We support both.
window_widthwith the number of pixels wide you want the screen to be
window_heightsame for the height
To simulate iPhone 6 that is 414x736 pixels.
The second part is to send a Custom Header called "User-Agent". Browsers use it to identify themselves, as do some HTTP clients (i.e., cURL).
User-Agents are long strings that often change since they contain browser and system versions. The best idea is to look for actual User-Agents and copy them.
We'll see another example using cURL.
This one will need a param
custom_headers set to true and a
-H modifier for the cURL command.
What comes was copied directly from a real User-Agent to avoid sending something wrong.
-H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1" \
You can test headers and parameters in our Builder. It will also output code in several languages.
As we said above, sending only the User-Agent might be disadvantageous in some cases. When trying to bypass efficient anti-bot systems, modifying this header by hand might raise a red flag. The reason is that browsers tend to send several headers together and with a specific value for some of them. That means it might send an iPhone User-Agent with another header that only comes with desktop Chrome.
If you find any trouble with that, contact us, and we'll help you set up your calls like a mobile user.