from grab import Grab
domen = "http://w...content-available-to-author-only...r.org"
link = "http://w...content-available-to-author-only...r.org/top"
monitoring_text = "Ex Machina"
raw_torrent_links_css_selector = "a[href^='/torrent/']"
found = {}
count = 1
g = Grab()
g.go(link)
raw_torrent_links = g.css_list(raw_torrent_links_css_selector)
for torrent in raw_torrent_links:
if torrent.text != None and (torrent.text.lower()).find(monitoring_text.lower())!= -1:
torrent_page = domen+torrent.attrib['href']
print(torrent_page)
link_to_torrent_file = torrent(torrent_page, g) # TypeError: 'HtmlElement' object is not callable. отдельно работает нормально
found[count] = [torrent.text, torrent_page]
count += 1
def torrent(url, grab_obj):
grab_obj.go(url)
rawtorrent = grab_obj.doc.select("//div[@id='download']/a[2]")
return rawtorrent.attr('href')
ZnJvbSBncmFiIGltcG9ydCBHcmFiCgpkb21lbiA9ICJodHRwOi8vdy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5vcmciCmxpbmsgPSAiaHR0cDovL3cuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnIub3JnL3RvcCIKbW9uaXRvcmluZ190ZXh0ID0gIkV4IE1hY2hpbmEiCnJhd190b3JyZW50X2xpbmtzX2Nzc19zZWxlY3RvciA9ICJhW2hyZWZePScvdG9ycmVudC8nXSIKZm91bmQgPSB7fQpjb3VudCA9IDEKCmcgPSBHcmFiKCkKZy5nbyhsaW5rKQpyYXdfdG9ycmVudF9saW5rcyA9IGcuY3NzX2xpc3QocmF3X3RvcnJlbnRfbGlua3NfY3NzX3NlbGVjdG9yKQoKZm9yIHRvcnJlbnQgaW4gcmF3X3RvcnJlbnRfbGlua3M6CglpZiB0b3JyZW50LnRleHQgIT0gTm9uZSBhbmQgKHRvcnJlbnQudGV4dC5sb3dlcigpKS5maW5kKG1vbml0b3JpbmdfdGV4dC5sb3dlcigpKSE9IC0xOgoJCXRvcnJlbnRfcGFnZSA9IGRvbWVuK3RvcnJlbnQuYXR0cmliWydocmVmJ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