WeChat browser, though easy to test in disguise

Source: Internet
Author: User

As we all know, the html5 interface of the project will be developed for a relatively long time (why is this not explained), and some problems that cannot be detected on the web end will occur in the browser, I have the idea of simulating a browser. After google, I found that there is a way to disguise the browser, that is, using the browser's user Agent (Each browser has its own different user Agent, in addition, you can use the user Agent to determine the token, UsedWhen a user initiates a request to the server through a browser, the request header (header) will contain ). After the installation is successful, you can see the Default User Agent option in the tool options. For example, after the test by the author,Is a specific Identifier of the browser, so the if statement in can determine whether the request is initiated by the browser. Note the following:In this paper, the author needs to use his own GT-I9300 to obtain the agent is: Open the Add new User Agent under the Default user agent to switch the user agent to the just built GT-9300 for testing: compare yourself to www.baidu.com the original look, it is added successfully.

String url = "http://www.where is your need.com" String userAgent = "Mozilla/5.0 (Linux; U; Android 4.1.2; zh-cn; GT-I9300 Build/JZO54K) "+" AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 MicroMessenger/5.2.380 "String html = getHttpClientHtml (url, "UTF-8" String html = HttpClient httpClient = DefaultHttpClient (); HttpGet httpget = HttpGet (url); httpget. setHeader ("User-Agent" HttpResponse responce = returnCode = (returnCode = HttpEntity entity = (entity! = Html = String (EntityUtils. toString (entity);} System. out. println ("exception occurred "}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.