I take an example from the documentation ( http://docs.grablib.org/ru/latest/grab/text_search.html#id2 ) and just copy it. He does not work. An error is issued

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/grab/util/warning.py:28: GrabDeprecationWarning: Call to deprecated function search. Use grab.doc.text_search instead. warn(message) 

All code:

 from grab import Grab g = Grab() url = 'https://news.yandex.ru/index.rss' g.go(url) g.search(u'яндекс'.encode('utf-8'), byte=True) 
  • one
    This is not a mistake, but a warning: use g.doc.text_search . The second point - try to search for "Yandex" (with a capital letter). The third point - try to print out what the method returns - awesoon
  • Excellent on all three points. 1. If you print out what sends the answer (code without edits), then swears and returns a fold. 2. If with a capital letter, then swears and labor. 3. If you use g.doc.text_search, then everything is ok. It is a shame that at random did not try to substitute. Thank you very much for the help! - danilenkodanila

1 answer 1

Use g.doc.text_search

The code looks like this:

 from grab import Grab g = Grab() url = 'https://news.yandex.ru/index.rss' g.go(url) print (g.doc.text_search(u'Яндекс'.encode('utf-8'), byte=True)) 

Thanks to @soon