Python language realizes the method of mobile phone number attribution __python

Source: Internet
Author: User
Now more and more rampant fraud, everyone received every day the strange harassment phone countless, now mobile phones have a function to show the ownership of phone calls, recently have their free time, online check, found that the use of Python development (http://www.maiziedu.com/course /python/) language, in Python using Delphi space to write the interface program, so they are hot to write a type of query scheme.     This example is by www.ip138.com this site to query, here are a few knowledge points, is to use Python Analog Web page submission data, access to data return information, as well as the return of   Html information to parse, simulate Http submission, Python comes with a urllib and Urllib2 library, which is quite handy, but it's just odd why it's easier to combine two libraries into one. Then there's the form, and the form is DXVCL with a Python module I wrote earlier, which is a module library that can invoke the Delphi interface control in Python. Here is the code, quite simply. #-*-coding:gb2312-*-import Urllib,urllib2,htmlparser from Dxvcl import* class Myparser (htmlparser.htmlparser):     def reset (self):         self._isintd = false                  self._retdata = []          HTMLParser.HTMLParser.reset (self)     def handle_starttag (Self,tag,attris):          SELF._ISINTD = Tag = = ' TD '     DEF handle_endtag (Self,tag):    &nbsp    if self._isintd:             self._isintd = False     def handle_data (self,data):         if self._isintd:       & nbsp     self._retdata.append (data) class MainForm (Form):     def__init__ (Self,owner):         self. Caption = ' Search for mobile phone ownership '         self. Position =5         self. BorderStyle =3         self. Width =303         self. Height =375         self.lbl = Label (self)          Self.lbl.SetProps (Parent = self,caption = ' mobile number ')         self.lbl.setbounds (16,8,60,13 )         self. Edtphone = Edit (self)         self. Edtphone.setprops (Parent = Self,text = ')         self. Edtphone.setbounds (77,3,121,21)         self. Button1 = Button (self)         self. Button1.setprops (Parent = self,caption = ' query ')         self. Button1.setbounds (204,1,75,25)         self. Button1.onclick = self. Button1Click         self. Memo1 = Memo (self)         self. Memo1.parent = self         self. Memo1.setbounds (16,32,263,297)         def Button1Click (self,sender):          postdata = Urllib.urlencode (' action ', ' Mobile '), (' Mobile ', self. Edtphone.text)]         req = urllib2. Request (' http://www.ip138.com:8080/search.asp ')         fd = Urllib2.urlopen (req, PostData)         h = Fd.read ()         my = Myparser ()         my.feed (h)         self. Memo1.Lines.Clear ()         for data in My._retdata:         & nbsp;   self. MEMO1.LINES.ADD (data) def main ():     Freeconsole ()     application.initialize ()     Applic ation. Title = ' Query phone attribution '     F = mainform (application)     f.show ()     Application.Run () if__name_ _== ' __main__ ': The interface after the run of Main ()  
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.