«Умный» способ сканирования Интернета

550
Puru

У меня есть проект, в котором мне нужно сканировать сеть lyrics, я его реализую depth-first searchи делаю базу данных в виде списка (который содержит вложенные списки, которые впоследствии будут сохранены в файле). Моя идея состоит в том, чтобы получить HTML-содержимое веб-сайта и сохранить его в файле, а затем проанализировать текст песни. Но проблема в том, что он очень медленный и мне не нужны страницы (рекламные ссылки) Есть ли какое-то решение или «лучше» было внедрить бота?

-1

2 ответа на вопрос

1
Dour High Arch

To give specific recommendations we'd have to see your code. However, HTML parsing is a very difficult problem; be sure to use an existing parsing library and don't attempt to create your own.

In general it is better to implement web-crawlers using breadth-first search and not depth-first. Depth-first searches often make many calls to the same domain and path; this can be detected by web sites and your crawler may be throttled or even blocked. Breadth-first crawlers avoid this and have more opportunities for optimizations; for example recognizing that two sites are copies of each other, and abandoning the slower site.

0
DrMoishe Pippik

Lyrics are often TXT, whereas ads are not, so you could restrict search to text. The negative aspect of that is that you'd certainly miss some HTML lyrics.