Use Python to find your mobile phone number attribution

Source: Internet
Author: User

A simple example, previously written in Dephi, was recently implemented in Python using the Delphi control to write the interface program, so hot write a similar query scheme.

This example is through the www.ip138.com this website to query, here need a few knowledge points, is to use Python Simulation Web page submit data, get data return information, and the return of HTML information to parse, simulate HTTP commit, Python comes with a urllib and Urllib2 library, which is quite handy, just wondering why it's easier to combine two libraries into one. Then there is the form, and the form is DXVCL by a Python module I wrote earlier, which is a library of modules that can invoke the Delphi interface control in Python. Here is the code, quite simple!

#-*-coding:gb2312-*-
ImportUrllib,urllib2,htmlparser
fromDXVCLImport*
classMyparser (Htmlparser.htmlparser):
defReset (self):
Self._isintd=False
Self._retdata= []
HTMLParser.HTMLParser.reset (self)
defHandle_starttag (Self,tag,attris):
Self._isintd=Tag=='TD'
defHandle_endtag (Self,tag):
ifSelf._isintd:
Self._isintd=False
defHandle_data (self,data):
ifSelf._isintd:
Self._retdata.append (data)


classMainForm (Form):
def__init__(Self,owner):
Self. Caption='Find your phone's place of ownership'
Self. Position=5
Self. BorderStyle=3
Self. Width=303
Self. Height=375
SELF.LBL=Label (self)
Self.lbl.SetProps (Parent=self,caption='Mobile phone number')
Self.lbl.SetBounds ( -,8, -, -)
Self. Edtphone=Edit (self)
Self. Edtphone.setprops (Parent=Self,text="')
Self. Edtphone.setbounds ( the,3,121, +)
Self. Button1=Button (self)
Self. Button1.setprops (Parent=self,caption='Enquiry')
Self. Button1.setbounds (204,1, the, -)
Self. Button1.onclick=Self . Button1Click
Self. Memo1=Memo (self)
Self. Memo1.parent=Self
Self. Memo1.setbounds ( -, +,263,297)
defButton1Click (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 ()
forDatainchMy._retdata:
Self. MEMO1.LINES.ADD (data)

defMain ():
Freeconsole ()
Application.initialize ()
Application.title='Find phone ownership'
F=mainform (application)
F.show ()
Application.Run ()

if__name__=='__main__':
Main ()

After running the interface

Use Python to find your mobile phone number attribution

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.