Hi i need help with that my code its:
keyword = input("")
engine = Google()
results = engine.search("site:anonfile.com " + str(keyword))
links = results.links()
file1 = open("results.txt","w")
file1.writelines(links)
file1.close()
print(links)
The results are saving like that
https://cdn-32.anonfile.com/B6Cau9Fbn7/6e7bf257-1576485241/x3152 Spotify Premium Account by The Jester.txthttps://cdn-04.anonfile.com/S4u7K9f1b7/ceaa1f97-1539376777/Spotify.txt
I want it to be saved as follows but I don't know how to do it :(
https://cdn-32.anonfile.com/B6Cau9Fbn7/6e7bf257-1576485241/x3152 Spotify Premium Account by The Jester.txt
https://cdn-04.anonfile.com/S4u7K9f1b7/ceaa1f97-1539376777/Spotify.txt
I use google translator, sorry if you don't understand what i say.
Related
I need to download all invoices from stripe.com for the past year for accounting purposes. I didn't find a button for that, and when I contacted stripe.com support, they said it's not possible and I should use API if I can.
I found this page, but it wasn't working. I didn't want to spend that much time on it, as I was sure this is a common use case and why fintech unicorn would not support this simple use case. Well, so I wrote a Python script for that and sharing it here. As I spend some time on it, I am sharing it here in the hope to be useful to somebody else as well.
These are the steps to create a new Stripe API Key:
Log in to your Stripe dashboard.
Got to the API Keys section.
Click on Create secret key or Create restricted key (recommended).
If you chose to use a restricted key, select the Invoices -> Read permission.
Hit Save, copy the Secret key and paste it in the STRIPE_KEY.
import os
import arrow
import requests
STRIPE_KEY = "{digrin.com}"
SAVE_PATH = "./Invoices/"
import stripe
def get_invoices(year):
last_item_id = None
result = []
while True:
invoices = stripe.Invoice.list(
api_key=STRIPE_KEY,
status='paid',
created={'gte': int(arrow.get(f"{year}-01-01").timestamp()), 'lte': int(arrow.get(f"{year}-12-31 23:59").timestamp())},
limit=100,
starting_after=last_item_id,
)
for invoice in invoices['data']:
result.append({"number": invoice['number'], "url": invoice['invoice_pdf']})
if not invoices['data']:
break
last_item_id = invoices['data'][-1]['id']
return result
if __name__ == "__main__":
invoices = get_invoices(2022)
print(f"There are {len(invoices)} invoices.")
for invoice in invoices:
with open(f"{SAVE_PATH}{invoice['number']}.pdf", "wb") as f:
f.write(requests.get(invoice['url']).content)
print(f"Saved file {invoice['number']}.pdf")
# check count
file_list = os.listdir(SAVE_PATH)
pdf_list = [file for file in file_list if file.endswith(".pdf")]
if len(pdf_list) != len(invoices):
print(f"WARNING: There are {len(invoices)} invoices but {len(pdf_list)} pdf files in the directory.")
else:
print(f"There are {len(pdf_list)} files in the directory, matches stripe response.")
Hey there i need to Pagenate this code can you guys please help me out i tried the docs but not able to get hold of it.
cases = db.collection(u'hospitals').document(request.session['hospital_email']).collection('cases').where(
u'status', u'==', "done").where("formstatus", "==", "draft").order_by(u'date').limit(3).get()
for i in cases:
cases_data[i.id] = i.to_dict()
print(cases_data[i.id], " ==>", i.to_dict())
print("")
I am developing APIs/ Frontend to add new data, stories, responses, entities, add actions , train bot, deploy bot etc .
I am updating backend nlu.md, stories.md, domain.yml etc and then execute rasa train, rasa shell etc in the backend.
Is there any rasa command available to add nludata effectively?
Currently, i am using python to add intents, entities etc to nlu.md file.
Logic has become complicated.
Below is sample code to add intents:
pathnlu = bot_name + "/data/nlu.md"
print("Bot id is", args['bot_id'])
if str(os.path.exists(pathnlu)):
f = open(pathnlu, "a")
f.write("\n")
f.write("## intent:")
f.write(intent.intent_name)
f.write("\n")
f.write("- ")
f.write(intent.intent_description)
f.close()
print("Intent ", intent.intent_name, " Created ")
else:
print("Unable to Create Intent")
Below is a sample code to add entities :
pathnlu = bot_name + "/data/nlu.md"
print("Bot id is", args['bot_id'])
if str(os.path.exists(pathnlu)):
f = open(pathnlu, "a")
f.write(intent.intent_description + "(" + entities + ")" + remaining_intent)
f.close()
print("entity", entities, " Added")
else:
print("Unable to add entities")
But, I am looking for some simple and robust way to accomplish it.
Please help.
Use Interactive learning in RASA, where your files will get updated
and In this mode, you provide feedback to your bot while you talk to
it. This is a powerful way to explore what your bot can do, and the
easiest way to fix any mistakes it makes. One advantage of machine
learning-based dialogue is that when your bot doesn’t know how to do
something yet, you can just teach it!
How to do it? - https://legacy-docs.rasa.com/docs/core/interactive_learning/
Ok, so I am having trouble trying to get my code to work, my goal is to make a Reddit Bot that refers to Steam's appid JSON to link users to the steam store page when the user says the name of a game.
The bot is almost complete, however, I keep getting "TypeError: list indices must be integers, not str" when the bot runs.
Here is my code:
import praw
import time
import json
import codecs
# Death Zone /// I hope you have coffee, brcause you won't leave until this is done
with open('API.json', encoding='utf-8-sig') as steam_strings:
dic = json.loads(steam_strings.read())
print("Successfully read JSON")
a = dic.get('appid')
n = dic.get('name')
[app['name'] for app in dic['applist']['apps']['app']]
# End Death Zone
app_id = 'CENSORED'
app_secret = 'CENSORED'
app_uri = 'https://127.0.0.1:65010/authorize_callback'
app_ua = 'Stop asking me how to get the Windows flair dummy, I am here for that reason'
app_scopes = 'account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modothers modposts modself modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread'
app_account_code = 'CENSORED'
app_refresh = 'CENSORED'
import praw
def login():
r = praw.Reddit(app_ua)
r.set_oauth_app_info(app_id, app_secret, app_uri)
r.refresh_access_information(app_refresh)
print("Steam Link Bot! Version Alpha 0.1.2")
return r
r = login()
words_to_reply = dic['applist']['apps']['app']['name']
# {'applist':1,'apps':2, 'app':3, 'name':4}
cache = []
def run_bot():
subreddit = r.get_subreddit("eegras")
comments = subreddit.get_comments(limit=100)
for comment in comments:
comment_text = comment.body.lower()
isMatch = any(string in comment_text for string in words_to_reply)
if comment.id not in cache and isMatch:
comment.reply(['applist']['apps']['app']['appid'])
cache.append(comment.id)
print("I replied to a comment successfully!")
while True:
run_bot()
time.sleep(10)
Any help would be appreciated, I'm kinda a beginner at Python, so take it easy.
This type of error is raised when it is accessed a list by a string , deferentially of dictionaries that allow be indexed by strings.
If possible comment line which occurs this error, or you can check the type of data making a print type and checking if it really is a dictionary . However make sure the JSON really is structured like a dictionary , or if there are lists inside.
I am trying to implement this into python, but I am having difficulty:
https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids
here is what I have:
def reqs():
t = Twitter(auth=OAuth('...'))
tweets = t.statuses.user_timeline.snl()
retweetids = t.statuses.retweeted_by(id=str(tweets[0]['id'])) <<does not work.
print retweetids
use
retweets
instead of retweeters