A web designer is a treasure that has been broken down for the last generation.

Source: Internet
Author: User
There are some amazing things in the world that can make a lot of awesome people die. Let's first look at a page http://www.skxox.com/xxinfo_425691.htmlwhich should be displayed on the browser. No gibberish occurs. View the source file to see this line. <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/> So, you are awesome to think that this page is gb2312 encoded... Now try to show the webpage in gb2313 encoding in the browser: A small number of Chinese Characters Nima, what the hell is this ...... Therefore, those on the blog park that automatically recognize the webpage code Article It's a lie... For the packet capture tool, see http/1.1 200 okdate: Thu, 21 APR 2011 07:36:27 gmtserver: Microsoft-IIS/6.0x-powered-by: Asp. netx-ASPnet-version: 2.0.50727x-powered-by: urlrewriter. net 1.7.0cache-control: privatecontent-type: text/html; charset = utf-8Content-Length: 41750 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> This is what it really code. So, I beg you not to analyze the charset in the web page. Encode the statement: String c = response. contenttype. replace ("text/html ;",""). replace ("charset = ",""). trim (); a lump Code : /// <Summary> /// Remote URL retrieval pageSource code
///   </Summary>
///   <Param name = "url"> URL of the page to be retrieved </Param>
///   <Returns> Return HTML code </Returns>
Public   Static   String Gethtml ( String URL, String Ucoid)
{
Httpwebrequest request =   Null ;
Httpwebresponse response =   Null ;
Streamreader =   Null ;
Try
{
Request = (Httpwebrequest) webrequest. Create (URL );
Request. useragent =   " Www.svnhost.cn " ;

Request. Timeout =   20000 ;
Request. allowautoredirect =   True ;
Response = (Httpwebresponse) request. getresponse ();
If (Response. statuscode = Httpstatuscode. OK && Response. contentlength <   1024   *   1024 )
{

String C = Response. contenttype. Replace ( " Text/html; " , "" ). Replace ( " Charset = " , "" ). Trim ();
If (Ucoid. isnullorempty ())
{
Ucoid = C;
}
Reader =   New Streamreader (response. getresponsestream (), system. Text. encoding. getencoding (ucoid ));

StringHtml=Reader. readtoend ();

Return HTML;
}
}
Catch {}
Finally
{
If (Response ! =   Null )
{
Response. Close ();
Response =   Null ;
}
If (Reader ! =   Null )
{
Reader. Close ();
}
If (Request ! =   Null )
{
Request =   Null ;
}
}
Return   String . Empty;
} So you can't afford the web designer .... They used to fall into the septic tanks all their life...

 

Source: http://www.njxsw.com/forum-viewthread-tid-1965-fromuid-4.html

 

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.