我正在将一个scrapy脚本运行到一个SQL数据库中,一切正常,但是当流式传输到discord时,链接会挂起,一遍又一遍地将新链接添加到上一个链接。
我在python 2.7上,不想在py3中重写它
我做错了什么/失踪了。 Discord IMG Example.
if any(keyword in item['name'].encode('utf-8').lower() for keyword in keywords):
# Twitter Auth - Tweet the item with date, time, item name, and link.
# To obtain Twitter CONSUMER and ACCESS keys go to https://apps.twitter.com/
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN_KEY = ''
ACCESS_TOKEN_SECRET = ''
API = TwitterAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
TEXT_TO_SEND = DATE + " EST " + item['name'] + " " + item['link']
TWEET = API.request('statuses/update', {'status': TEXT_TO_SEND})
print(Fore.RED + 'TWEET LOG SUCCESS: ' + DATE + ' EST ' + item['name'] + ' ' + item['link'] + Style.RESET_ALL if TWEET.status_code == 200 else Fore.RED + 'TWEET LOG FAILURE: FAILED TO TWEET' + Style.RESET_ALL)
# WebHook for Discord. Comment/Uncomment the line below to enable/disable.
embed.set_author(name='New Off-White Item', icon='https://s3.amazonaws.com/spoonflower/public/design_thumbnails/0359/0799/rstripes_2_repeat_preview.png')
embed.set_desc(item['name'])
embed.add_field(name='Link:',value=item['link'])
embed.add_field(name='ATC',value=item['size'])
embed.set_thumbnail(item['image'])
embed.set_footer(text='@userRestock',icon='https://cdn.shopify.com/s/files/1/2760/3186/products/Doggo_Transparent_1024x1024@2x.png?v=1524521026',ts=True)
embed.post()
# WebHook for Slack. Comment/Uncomment the line below to enable/disable.
# requests.post('SLACK WEBHOOK URL', json={'text': "*" + item['name'] + "*" + "\n" + item['link'] + "\n" + "\n" + "[ATC]: " + item['size'] + "\n" + "------------" + "\n"}, headers={'Content-Type': 'application/json'})
except MySQLdb.Error, e:
# print (Fore.RED + "MYSQL ERROR %d: %s" % (e.args[0], e.args[1] + Style.RESET_ALL))
return item