What is the User Agent?
The Chinese name of User Agent is "User Agent" (UA). It is a special string header, which refers to an identifier provided to you by the software (software Agent) that represents User behavior. It enables the server to identify the browser type and version, operating system and version, browser kernel, and other information used by the customer.
A piece of code used in a browser is actually used to indicate the identity of the browser.
Some websites often send different pages to different operating systems and browsers by judging the UA. Therefore, some pages may not be displayed normally in a browser, however, by disguising UA, we can bypass detection. In this way, we can easily use a PC browser to simulate a mobile browser.
User Agent format
The format is as follows:
Browser ID (operating system ID; encryption level ID; browser language) rendering engine id version information
<-In fact, it is still a bit confusing. You can check it yourself. ->
How to view the User Agent?
Write your own code
Detection websites and detection information are all explained. Combined with the above format, we can understand it.
Http://whatsmyuseragent.com/
Http://whatsmyua.com/
Http://www.useragentstring.com/
Simulate a mobile browser with a PC browser (I): no extended version
Chrome-developer tool drop settings
There are actually corresponding User Agent settings in the settings of Chrome browser developer tools. You only need to select the User Agent of the corresponding system to simulate the corresponding browser. The method is as follows:
Open Chrome's developer tool, press Ctrl + Shift + I to open it, or right-click to review elements, and so on.
In the lower-right corner of the developer tool (the location may vary depending on the version), click the gear-like setting button.
The second item "Overrides" in "settings" is "User Agent", which is checked to select the corresponding mainstream User Agent. Of course, select the last "Other" and you can add the User Agent you need.
After selecting the corresponding User Agent, if the current browser URL is a PC page and the User Agent is used as the judgment standard, the refresh will jump to the corresponding mobile phone page. Similarly, if you directly access the mobile phone page, you will not jump to the page.
Remember: the developer tool needs to be turned on all the time.
In addition, "Overrides" can also simulate the screen size, geographical location, touch events, and CSS media functions of the device. It is powerful enough.
PS: It is said that someone has used the geographic location simulation function to successfully simulate their own microblogs and QQ posts around the world. If you want? Pankenclose? Yi Xiaoyun Garden sang? Why ?? Too many tasks? Yan Deng Lang? /P>
As shown in the following figure, the current Chrome version is 28.0.1500.95 m. If you do not have this function, upgrade it.
Safari-user agent
Safari also has the corresponding function, which is called "User proxy" here ".
First, in the upper-right corner of the browser, choose "Settings"> "preference settings"> "advanced", and check the "display" development "menu in the menu bar.
Then there will be another "development" in the menu bar, "user agent" under "Development", OK, you understand.
Of course, there are others at last. You can add them by yourself.
Simulate a mobile browser using a PC browser (2): plug-in version
Firefox plugin
In fact, there is only one plug-in, and others are also useful.
User Agent Switch, master.
Wmlbrowser should be mainly used to parse xml. The earliest wap sites are not xml. This can be added, but it does not need to be added. Do you need to check the xml wap.
XHTML Mobile Profile, which seems dispensable. What does it mean to parse xhtml on the Mobile end?
After the plug-in is installed, it will be OK. A "Default User Agent" will be added under "Tools" in the menu bar of Firefox. You will see what you want. As shown in the following figure:
I don't know what this plug-in is like. I don't have several major User agents built in, but it's okay to create or import them in batches. As shown in the following figure:
The following is a list of UA files created by fisio in xml for your reference: List of commonly used UA files. Address: List of commonly used UA files.
Chrome plugin
The plug-in on Chrome is also User-Agent Switcher for Chrome.
After the installation, the location of Chrome is quite good and the debugging is simple. In the upper right corner, as shown in the figure
You can also add or import some built-in UA.
Simulate a mobile browser using a PC browser (3): Start the version with the User-Agent parameter
Start the browser directly with the User-Agent as the parameter. The browser started with the user-agent will be simulated as the browser, even if you open the same browser separately, it will be the same as the simulated browser. If you want to switch back to the normal browser mode, you can only close all Chrome browsers and then open them normally. Moreover, it can only be used in Chrome browsers. It can be seen that Chrome is powerful, and I understand it as well. Oh, just like the same kernel.
The following three types of browser startup are available:
I. Command line startup
In the window system, "start"-"run" or "Win + R", and then enter the corresponding code to open the corresponding UA browser.
The code format is as follows:
Chrome.exe + space + "-user-agent = 'ua '"
For example, open the browser with the UA of IPhone 4:
Chrome.exe-user-agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) version/5.0.2 Mobile/8H7 Safari/6533.18.5"
Some say that after cmd is enabled, you must first go to the Chrome installation directory (what path \ Application \ chrome.exe.pdf can be executed, but it is actually a different tool. If it is done directly, go to the chrome.exe directory.
Disadvantage: you have to copy each time and have to find the corresponding UA. Please try again. Let's look at the following two types.
II. Desktop shortcut startup
Add the corresponding UA after the target option parameter of Chrome's desktop shortcut, so that the browser starts directly with the added UA.
The target parameter format is as follows:
The original parameter + space + "-user-agent = 'ua" in the target option '"
But there is only one shortcut. What should I do? Copy a few more, such as Chrome-Android, Chrome-IPhone, and Chrome-IPAD,
III. Batch processing script startup
Of course, you can also set up a batch processing script to start, which is more convenient.
Create a new notepad and paste the following content:
@ Echo off
Start chrome.exe -- user-agent = "UA"
EXIT
@ Echo off
Start chrome.exe -- user-agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) version/5.0.2 Mobile/8H7 Safari/6533.18.5"
EXIT
After completion, change the suffix of the cmd.txt file to the suffix ". bat" to disable Chrome. Double-click the File to access the website, OK, and the mobile version.
Similarly, you can create multiple UA IDs.
Remember: If you want to switch back to the normal browser mode, you can only close all Chrome browsers and then open them normally. Alternatively, use the UA of the normal Chrome browser to simulate it.
If this parameter is set, use the PC browser to simulate the mobile browser.