A
A
Alexander Isaev2016-10-18 20:14:42
ruby
Alexander Isaev, 2016-10-18 20:14:42

How to find out the artist's yandex id?

Hello everyone) Guys, there is such a task - you need to find the yandex id of the artist. Wrote a program in ruby ​​and seems to find it. But this only works for two performers. And then Yandex blocks. And what do we need for 500 performers? I tried to specify UserAgent, Accept-Encoding and other request headers in the request. And Yandex no longer blocks. But in the output there is only some incomprehensible character. In general, I do not know how to solve the problem. Please help)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2"
host = "music.yandex.ru"
accept = "text/html,application/xhtml+xml,application/xml;q=0.9,
connection = "keep-alive"
requests = "1"
language = "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"
encoding = "gzip, deflate, br"
content = "text/html; charset=utf-8"
contentoding = "gzip"
a = 'sia'
html = " https://music.yandex.ru/handlers/music-search.jsx?... "
uri = URI. parse(URI.encode(html.strip))
puts @doc = Nokogiri::HTML(open(uri, 'User-Agent' => user_agent, 'Host' => host, 'Content-Type' => content, ' Accept' => accept, 'Connection' => connection, 'Accept-Encoding' => encoding), nil, "UTF-8")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question