How to extract Google music search results using Python

Source: Internet
Author: User
This article mainly introduces how to extract Google music search results using Python. It involves Python's Acquisition Techniques for Google music-related information and has some reference value, for more information about how to extract Google music search results using Python, see the following example. Share it with you for your reference. The details are as follows:

A simple Python script is used to extract the song information on the Google music search page, including the song name, author, album name, and current link. Only 10 pages of results can be extracted.

#! /Usr/bin/env python # coding = UTF-8 ''' Created on 2011-8-19 @ author: yaoboyuan ''' from urllib import request, parseimport re, sysdef extractSongRawData (text ): 'capture the raw data of each song 'text = re. sub ('\ n +', '', text) songList = re. findall ('\
 < tbody>
  
', Text) nums = len (songList) print ('search' + str (nums) + 'song') return songListdef translate (text):' Remove useless characters in text, convert unicode code 'text = re. sub ('\
  ', '', Text) text = re. sub ('\', '', Text) # find the and translate into chinese s = re. findall ('& # ([0-9] +);', text) if len (s) <= 0: return text else: text = ''for I in range (len (s): value = int (s [I], 10) # from str '000000' to 10 base's int 123 text + = chr (value) # from value to char return textdef extractSongName (song ): 'extract song name' td = re. findall ('(? :\) ', Song) name = re. findall ('. +? \(.*?) \ ', Td [0]) authorName = name [0] authorName = translate (authorName) return authorNamedef extrackAlbumName (song): 'extract album name' td = re. findall ('(? :\0: return td [0] else: return songdef extractLink (song): 'extract song download link 'td = re. findall ('''\
 <>

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.