python爬虫之移动端模拟!

一般情况下,网站是通过对http请求的header 进行识别来判断是访问的是pc还是手机,哪个版本的浏览器

所以,可以通过修改header的方法来模拟手机。

例如下面就是模仿了安卓4.3b版本的手机,androidN1浏览器

headers = { ‘User-Agent’:’Mozilla/5.0 (Linux; U;

Android 4.3; en-us; SM-N900T Build/JSS15J)

AppleWebKit/534.30 (KHTML, like Gecko) Version/4

.0 Mobile Safari/534.30′}

注:想学习Python的小伙伴们进群:984632579领取从0到1完整学习资料 视频 源码 精品书籍 一个月经典笔记和99道练习题及答案

而需要改变手机胡uozhe浏览器参数的话,可以参照下面的内容,修改User-Agent即可

Android QQ浏览器 For android

《python爬虫之移动端模拟!》

Android UC For android

《python爬虫之移动端模拟!》

备注: 320*480 是设备的分辨率,可以修改.

Android Firefox手机版Fennec

Android Pad Moto Xoom

《python爬虫之移动端模拟!》

iPhone3

《python爬虫之移动端模拟!》

iPhone4

《python爬虫之移动端模拟!》

iPad

《python爬虫之移动端模拟!》

BlackBerry

《python爬虫之移动端模拟!》

WebOS HP Touchpad

《python爬虫之移动端模拟!》

Nokia N97

《python爬虫之移动端模拟!》

Windows Phone Mango

《python爬虫之移动端模拟!》

Windows Phone Mango的User Agent格式为:Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0;厂商;型号[;运营商])

    原文作者:编程新视野
    原文地址: https://www.jianshu.com/p/ebb290554e39
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞