Trying to reduce the links received from another site using bitly.
for item in rss.findAll('item')[::-1]: title_raw = item.title.string date_end = title_raw.find(' - ') if date_end != -1: item_day = int(title_raw[0:title_raw.find(' ')]) title = title_raw.string[date_end+3:] day_word = u'сегодня' if item_day == current_day.day else u'завтра' link_raw = item.guid.string link = bitly.shorten(link_raw[0:link_raw.find('?')]) Then get the error:
Traceback (most recent call last): File "C: /Git/announce_cinema/holiday.py", line 47, in link = bitly.shorten (link_raw [0: link_raw.find ('?')]) TypeError: _ ( ) takes exactly 0 arguments (1 given)
Can you please tell me how to solve the problem?
link_raw, sofind('?')Can return-1sobitly.shorten()getslink_raw[0:-1]. Check this value (is it a URL?) 2. What does this lead to TypeError and not ValueError is probably a bitly bug (where did you get this package?) 3. You could use the urlparse module to get the necessary part of the URL. Also use the feedparser module to recognize rss instead of trying to do it by hand using BeautifulSoup. - jfs