Python crawler writes LOL record queries in Python

Source: Internet
Author: User

Introduce a simple Python crawler, create a client through Tkinter, when entering the LOL user name to query, you can display the current user's server, the current battle force and the current segment.

Crawl Web page address: http://lol.duowan.com/zdl/

Python version: 2.7

Modules needed: Tkinter urllib2 JSON sys

Instance code:

ImportUrllib2, JSON, threading fromTkinterImport*Importsysreload (SYS) sys.setdefaultencoding ('Utf-8')defGet_zhanji (): Name=Str (et.get ()) URL='http://api.lolbox.duowan.com/api/v2/player/search/?player_name_list=%s&callback= jQuery111200161216930093'           '95033_1470488155157&_=1470488155158'%Name Res=urllib2.urlopen (URL) HTML= Res.read () [44:-1]    PrintHTML Zhanji= json.loads (HTML) [u'player_list'] T.delete (0.0, END) forIinchZhanji:Print 'Server:%s Current Battle Force:%s'% (i['Game_zone']['alias'], i['Box_score'])        Print 'current Dan:%s'% (i['Tier_rank']['Tier']['FULL_NAME_CN'] + i['Tier_rank']['Rank']['name'])        #print i[' game_zone ' [' Alias ']        #Print Zhangji        #Print HTMLT.insert (END,'Server:%s Current Battle Force:%s'% (i['Game_zone']['alias'], i['Box_score']) T.insert (END,'current Dan:%s\n'% (i['Tier_rank']['Tier']['FULL_NAME_CN'] + i['Tier_rank']['Rank']['name']))defRukou ():ifEt.get () = ="':        Print 'Please enter the name of the Summoner'    Else: Get_zhanji ()#def qidong ():#T1 = Threading. Thread (Target=rukou)#T1.start ()#Get_zhanji ()#Print Len (jquery11120016121693009395033_1470488155157 ()Root=Tk () root.title ('lol record Search') root.geometry () et= Entry (Root, font= ('Song body,') ) Et.grid () b= Button (Root, text='Start Query', Font= ('Song body,'), command=Rukou) B.grid () T= Text (Root, font= ('Song body,')) T.grid () Root.mainloop ()

Interface Effect Display:

Python crawler writes LOL record queries in Python

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.