| 59 | 网易云爬取API |
| 60 | """ |
| 61 | def __init__(self, timeout=60, cookie_path='.'): |
| 62 | self.headers = { |
| 63 | 'Accept': '*/*', |
| 64 | 'Accept-Encoding': 'gzip,deflate,sdch', |
| 65 | 'Accept-Language': 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', |
| 66 | 'Connection': 'keep-alive', |
| 67 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 68 | 'Host': 'music.163.com', |
| 69 | 'Referer': 'http://music.163.com/search/', |
| 70 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36' |
| 71 | } |
| 72 | self.session = requests.Session() |
| 73 | self.session.headers.update(self.headers) |
| 74 | self.session.cookies = cookiejar.LWPCookieJar(cookie_path) |
| 75 | self.download_session = requests.Session() |
| 76 | self.timeout = timeout |
| 77 | self.ep = Encrypyed() |
| 78 | |
| 79 | def post_request(self, url, params): |
| 80 | """ |