3.2.5.4 Analysis Blacklist

Source: Internet
Author: User

If you are developing applications for mobile phones, such as getting a list of blacklisted phone numbers from the cloud center, however, these phone numbers are returned as a text file, and you need to analyze these lines of text into the number of telecom vendors, phone numbers, notes, tags, In fact, this process is to convert the serialized information into structured information, so that it can be more convenient to handle, such as the phone number out as a comparison of interception.

Example:

Text = "" "18701808546 1 user scam number (2015-08-24)

15396989999 1 -User harassment number (2015-08-23)

15992460848 1 -user scam number (2015-08-23)

15625759163 1 users promotion, intermediary (2015-08-23)

15994768049 1 users send scam information (2015-08-23)

18670826757 1 -user scam number (2015-08-22)

13141465810 1 -user scam number (2015-08-22)

13860039526:1 bit user fraud number (2015-08-22) "" "

Entries = Re.split ("\n+", text)

Print (entries)

L = [Re.split (":?", entry, 2) for entry in entries]

Print (L)

Print (' \ n output phone number:')

For phone in L:

Print (Phone[0])

The resulting output is as follows:

[' 18701808546 1bit user scam number(2015-08-24) ', ' 15396989999 1User Harassment number(2015-08-23) ', ' 15992460848 1bit user scam number(2015-08-23) ', ' 15625759163 1user promotion, intermediary(2015-08-23) ', ' 15994768049 1users to send fraudulent information(2015-08-23) ', ' 18670826757 1bit user scam number(2015-08-22) ', ' 13141465810 1bit user scam number(2015-08-22) ', ' 13860039526:1bit user scam number(2015-08-22) ']

[[' 18701808546 ', ' 1bit user scam number' , ' (2015-08-24) ', [' 15396989999 ', ' 1User Harassment number' , ' (2015-08-23) ', [' 15992460848 ', ' 1bit user scam number' , ' (2015-08-23) ', [' 15625759163 ', ' 1user promotion, intermediary' , ' (2015-08-23) ', [' 15994768049 ', ' 1users to send fraudulent information' , ' (2015-08-23) ', [' 18670826757 ', ' 1bit user scam number' , ' (2015-08-22) ', [' 13141465810 ', ' 1bit user scam number' , ' (2015-08-22) ', [' 13860039526 ', ' 1bit user scam number' , ' (2015-08-22) ' ]

Output Phone Number:

18701808546

15396989999

15992460848

15625759163

15994768049

18670826757

13141465810

13860039526

In this example, re.split ("\n+", text) is used to remove multiple lines of empty lines, so that all text is close together, using [Re.split (":?", entry, 2) for entry in Entries] to split each line of text into usable information format, and up to three groups of ways, and finally by traversing the list l can get all the phone number results, so when there is a caller display, You can tell if the number is in these lists, if you hang up the phone, block all harassment calls, advertising calls, improve the efficiency of the whole society, like this annoying phone will always interrupt you during the working hours, when you just sleep in bed when you call, or in the process of driving constantly, bring a lot of problems.



Cai Junsheng qq:9073204 Shenzhen

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

3.2.5.4 Analysis Blacklist

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.