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?

  • For starters, what is bitly and where did you get it from? - andreymal
  • Service links reduction bitly.com , which has its own api. The above code connects to api - silenoz
  • I already understood this, but what exactly is api for? Google says there are several of them - andreymal
  • 1. There is probably no question mark in link_raw , so find('?') Can return -1 so bitly.shorten() gets link_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
  • I use bitly_api github.com/bitly/bitly-api-python - silenoz

0