C # to get the phone attribution function

Source: Internet
Author: User

Today, through the search of data to understand the Web page crawl function, the application of HttpWebRequest and HttpWebResponse functions, from the http://www.showji.com site to capture the attribution of information

It should be said that this method is learned from other forums, the process is as follows:

Through the IE9 network monitoring function:

By analyzing the captured data, you will get the information of the place of attribution.

Analyze a piece of data we can get the following information

Returned is a JSON data, we pass the http://api.showji.com/locating/www.show.ji.c.o.m.aspx?m=18311095178&output=json& callback=querycallback&timestamp=1411465926173 This web site can also get the relative JSON data;

When we intercept this URL from the back of the phone and use the first half of it, the page data becomes the following: XML file

The rest of the steps are simple, as long as the XML file obtained by the analysis, we can get the data we want

Web page specific code is as follows

1  protected voidButton1_Click (Objectsender, EventArgs e)2         {3             stringPhone = This. Txt_con.text;4             stringURL ="http://api.showji.com/Locating/www.show.ji.c.o.m.aspx?m="+Phone;5 6             foreach(stringIteminchgethttpxml (URL))7             {8 9TextBox1.Text + = Item +"\ n";Ten             } One         } A  -          Public string[] Gethttpxml (stringURL) -         { theXmlDocument XML =NewXmlDocument (); - XML. Load (URL); -             -XmlNamespaceManager XMLNM =NewXmlNamespaceManager (XML. NameTable); +Xmlnm.addnamespace ("content","http://api.showji.com/Locating/"); -XmlNodeList nodes = XML. SelectNodes ("//content:queryresult|//content:mobile|//content:province|//content:city|//content:corp|//content:card|// Content:areacode|//content:postcode", XMLNM); +             if(Nodes. Count = =8) A             { at                 if("True". Equals (nodes[1]. InnerText)) -                 { -  -                     return New string[] {"Phone Number:"+nodes[0]. InnerText,"Operating provider:"+nodes[2]. InnerText,"Province of Attribution:"+nodes[3]. InnerText,"Attribution City:"+nodes[4]. InnerText,"City Area code:"+nodes[5]. InnerText,"City Zip code"+nodes[6]. InnerText}; -                 } -             } in             return New string[] {"FALSE" }; -}

Operating effect:

C # to get the phone attribution function

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.