I am using InstaBot Python API its working fine for Instagram Likes, But if i set only follow then nothing is happened. I tried a lot to fix this but did not get Proper solution. Could any one please let me know where i am worng in the code ? Here is my code :
bot = InstaBot(
login = 'xyz',
password = 'xyz',
like_per_day = 0,
comments_per_day = 0,
tag_list = '',
tag_blacklist = ['rain', 'thunderstorm'],
user_blacklist = {},
max_like_for_one_tag= 50,
follow_per_day = 10,
follow_time = 1 * 60,
unfollow_per_day = 0,
unfollow_break_min = 120,
unfollow_break_max = 180,
log_mod = 0,
proxy = '',
comment_list=[
["photo", "picture", "pic", "shot", "snapshot"],
],
# Use unwanted_username_list to block usernames containing a string
## Will do partial matches; i.e. 'mozart' will block 'legend_mozart'
### 'free_followers' will be blocked because it contains 'free'
unwanted_username_list=[
'second', 'stuff', 'art', 'sex', 'food', 'blog',
],
unfollow_whitelist=['example_user_1', 'example_user_2']
)
Please Help me to Fix my problem
Your tag list is empty. You need to set some tags for the bot to search so it can follow the people. I'd also recommend updating your default values so it's a bit easier for you to comprehend the configurations. You can build this up over time when you decide to use different features.
I'd recommend reading over the README.md for instructions on how to use the bot
(assuming this is the one you're using - the configurations look familiar to me)
bot = InstaBot(
login = 'xyz',
password = 'xyz',
like_per_day = 0,
comments_per_day = 0,
tag_list = ['sun', 'sea', 'water'],
tag_blacklist = [],
user_blacklist = {},
max_like_for_one_tag= 50,
follow_per_day = 10,
follow_time = 1 * 60,
unfollow_per_day = 0,
unfollow_break_min = 120,
unfollow_break_max = 180,
log_mod = 0,
proxy = '',
comment_list=[],
unwanted_username_list=[],
unfollow_whitelist=[]
)
Related
i have a sql query which basically retrieves coin names and submits an order for each coin.
However, it only submits an order on one coin and fails to loop through the rest, not sure why thats happening .
import sys
**
import pandas as pd
postgreSQL_select_Query = "SELECT base,quote FROM instrument_static where exchange='ftx'"
cursor.execute(postgreSQL_select_Query)
row=([y for y in cursor.fetchall()])
for i in row:
base=i[0]
quote=i[1]
portfolioItems = [
{
'exchange': 'ftx',
'base': base,
'quote': quote,
'amount': 0.01,
},
]
def init():
username = us
password = passwordVal
initialise(clientId, clientSecret, us, password)
if __name__ == "__main__":
init()
result = construct_portfolio_with_params(us, portname, portfolioItems)
print(result)
You need to initialize portfolioItems prior to the loop, and then you can add to it. Try replacing this snippet of code:
...
row=([y for y in cursor.fetchall()])
portfolioItems = []
for i in row:
base=i[0]
quote=i[1]
portfolioItems.append(
{
'exchange': 'ftx',
'base': base,
'quote': quote,
'amount': 0.01,
}
)
...
I have the following development which I'm working with the ElementTree and Pandas module in Python:
import xml.etree.ElementTree as ET
import pandas as pd
file_xml = ET.parse('example1.xml')
rootXML = file_xml.getroot()
def transfor_data_atri(rootXML):
file_xml = ET.parse(rootXML)
data_XML = [
{"Name": signal.attrib["Name"],
# "Value": signal.attrib["Value"]
"Value": int(signal.attrib["Value"].split(' ')[0])
} for signal in file_xml.findall(".//Signal")
]
signals_df = pd.DataFrame(data_XML)
extract_name_value(signals_df)
def extract_name_value(signals_df):
#print(signals_df)
signal_ig_st = signals_df[signals_df.Name.isin(["Status"])]
row_values_ig_st = signal_ig_st.T
vector_ig_st = row_values_ig_st.iloc[[1]]
signal_nav_DSP_rq = signals_df[signals_df.Name.isin(["SetDSP"])]
row_values_nav_DSP_rq = signal_nav_DSP_rq.T
vector_nav_DSP_rq = row_values_nav_DSP_rq.iloc[[1]]
signal_HMI_st = signals_df[signals_df.Name.isin(["HMI"])]
row_values_HMI_st = signal_HMI_st.T
vector_HMI_st = row_values_HMI_st.iloc[[1]]
signal_delay_ac = signals_df[signals_df.Name.isin(["Delay"])]
row_values_delay_ac = signal_delay_ac.T
vector_delay_ac = row_values_delay_ac.iloc[[1]]
signal_AutoConfigO_Rear = signals_df[signals_df.Name.isin(["AutoConfigO_Rear"])]
row_values_AutoConfigO_Rear = signal_AutoConfigO_Rear.T
vector_AutoConfigO_Rear = row_values_AutoConfigO_Rear.iloc[[1]]
signal_ACO_Front = signals_df[signals_df.Name.isin(["AutoConfigO_Front"])]
row_values_ACO_Front = signal_ACO_Front.T
vertor_ACO_Front = row_values_ACO_Front.iloc[[1]]
signal_ACO_Drvr = signals_df[signals_df.Name.isin(["AutoConfigO_Drvr"])]
row_values_ACO_Drvr = signal_ACO_Drvr.T
vector_ACO_Drvr = row_values_ACO_Drvr.iloc[[1]]
signal_ACO_Allst = signals_df[signals_df.Name.isin(["AutoConfigO_Allst"])]
row_values_ACO_Allst = signal_ACO_Allst.T
vector_ACO_Allst = row_values_ACO_Allst.iloc[[1]]
signal_RURRq_st = signals_df[signals_df.Name.isin(["RUResReqstStat"])]
row_values_RURRq_st = signal_RURRq_st.T
vector_RURRq_st = row_values_RURRq_st.iloc[[1]]
signal_RURqSy_st = signals_df[signals_df.Name.isin(["RUReqstrSystem"])]
row_values_RURqSy_st = signal_RURqSy_st.T
vector_RURqSy_st = row_values_RURqSy_st.iloc[[1]]
signal_RUAudS_st = signals_df[signals_df.Name.isin(["RUSource"])]
row_values_RUAudS_st = signal_RUAudS_st.T
vector_RUAudS_st = row_values_RUAudS_st.iloc[[1]]
signal_DSP_st = signals_df[signals_df.Name.isin(["DSP"])]
row_values_DSP = signal_DSP.T
vector_DSP = row_values_DSP.iloc[[1]]
print('1: ', vector_ig_st)
print('2: ', vector_nav_DSP_rq)
print('3: ', vector_HMI_st)
print('4: ', vector_delay_ac)
The output of the above is the following, they are the first 4 prints and it is fine, because it is what they want, but I have to simplify the code, so that any type of xml file of the type example.xml, can be read not only example1.xml:
The simplified code is required to bring the data as it is in the names_list variable, but not to use this variable, which is actually hard-coded:
names_list = [
'Status', 'SetDSP', 'HMI', 'Delay', 'AutoConfigO_Rear',
'AutoConfigO_Front', 'AutoConfigO_Drvr','AutoConfigO_Allst',
'RUResReqstStat', 'RUReqstrSystem', 'RUSource', 'DSP'
]
So when the client wants to put another XML file with the same structure, but with other names that are not in the code, it can read them without problem. Beforehand thank you very much.
I hope I'm understanding the questions correctly. my understanding is that
you want to dynamically produce the extract_name_value() function, and make it not as bulky in your code.
Im sorry, but I failed to comprehend the for i in signal_name: print(i) part of the question. perhaps you can rephrase the question, and help me understand?
my solution to the extract_name_value() part would be using the exec() function.
it is a built-in solution for dynamic execution.
name_list = ['Status', 'SetDSP', 'HMI', 'Delay', 'AutoConfigO_Rear',
'AutoConfigO_Front', 'AutoConfigO_Drvr', 'AutoConfigO_Allst',
'RUResReqstStat', 'RUReqstrSystem', 'RUSource', 'DSP']
def _build_extract_name_value_func(name_list):
extract_name_value_func = ""
for name in name_list:
holder_func = f"""
signal_{name} = signals_df[signals_df.Name.isin([{name}])]
row_values_{name} = signal_{name}.T
vector_{name} = row_values_{name}.iloc[[1]]
vector_list.append(vector_{name})
"""
extract_name_value_func += holder_func
return extract_name_value_func
def extract_name_value(name_list):
extract_name_value_func = build_extract_name_value_func(name_list)
exec(extract_name_value_func)
the code was not tested with actual data, because I am not familiar with handling xml structures. But I hope the python part can be some help to you.
I was able to solve it, I used a for loop and iterated the dataframe itself:
for i in signals_df.Name:
signal = signals_df [signals_df.Name.isin ([i])]
row_values = signal.T
vector = row_values.iloc [[1]]
print (vector)
I'm trying to call a soap webservice.
https://api.accounting.twinfield.com//webservices/finder.asmx?wsdl
It takes ArrayOfArrayOfString as a parameter. When I do a get_type on it,
emptyArrayPlaceholder = proces2.get_type("ns0:ArrayOfArrayOfString")
options1 = emptyArrayPlaceholder()
print(options1)
gives
{
'ArrayOfString': []
}
I've tried a few combinations but can't seem to find the right one.
EmptyString = proces2.get_type('ns0:ArrayOfString')
emptyArrayPlaceholder = proces2.get_type("ns0:ArrayOfArrayOfString")
options1 = EmptyString()
print(options1)
options2= EmptyString()
print(options1)
options1['string'].append('office')
options1['string'].append('072')
options2['string'].append('dimtype')
options2['string'].append('DEB')
options4 = emptyArrayPlaceholder()
options5 = emptyArrayPlaceholder()
options4['ArrayOfString'].append(options1)
options5['ArrayOfString'].append(options2)
options6 = emptyArrayPlaceholder()
options6['ArrayOfString'].append(options4)
options6['ArrayOfString'].append(options5)
options7 =[options4,options5]
print(options6)
responz = proces2.service.Search(type = "DIM", field = 0, firstRow = 1, maxRows = 0, options = options7, _soapheaders={'Header': header_value})
I've tried it with any of these options. A correct xml call would look like this:
<Search xmlns="http://www.twinfield.com/">
<type>DIM</type>
<pattern>*</pattern>
<field>0</field>
<firstRow>1</firstRow>
<maxRows>0</maxRows>
<options>
<ArrayOfString>
<string>office</string>
<string>072</string>
</ArrayOfString>
<ArrayOfString>
<string>dimtype</string>
<string>PNL</string>
</ArrayOfString>
</options>
</Search>''
Any ideas?
I have a python script that is requesting data from the database through the code below:
from datetime import datetime
import re
global dateTimeObj
dateTimeObj = datetime.now()
path = db.collection(u'users').document(u'a#a.com')
doc_ref = path.collection(u'feedback').order_by(u'time_stamp').stream()
for doc in doc_ref:
a = u'{} => {}'.format(doc.id, doc.to_dict())
print(a)
output:
feedback_1 => {'feedback_sub_item': 'feedback sub item', 'feedback': 'feedback message', 'record_id': '111', 'cycle_id': 'normal', 'rating': 3.5, 'time_stamp': '02/28/2020 16:15:58'}
feedback_2 => {'feedback_sub_item': 'feedback sub item', 'feedback': 'feedback message', 'record_id': '112', 'cycle_id': 'normal', 'rating': 4, 'time_stamp': '02/28/2020 16:16:52'}
My question is, how I can convert this message to extract the parameters from the last feedback based on the time_stamp field?
My desired output is:
Feedback_number = feedback_2
feedback_sub_item = feedback sub item
feedback = feedback message
record_id = 112
cycle_id = normal
rating = 4
time_stamp = 02/28/2020 16:16:52
thnks
To extract the dictionary, you can use the split function. Then you can iterate through this dictionary with its keys.
To do this, you can use a 'for' loop to display the values contained in the dictionary.
# a is your last feedback
new_list = a.split("=>")
new_dict = eval(new_list[1])
print("feedback_number = ", new_list[0])
for key in new_dict:
print(key," = ",new_dict[key])
With this exemple your obtain:
feedback_number = feedback_2
feedback_sub_item = feedback sub item
feedback = feedback message
record_id = 112
cycle_id = normal
rating = 4
time_stamp = 02/28/2020 16:16:52
I hope that answers your question
The function's return not meeting expectations.
My env py2.7.11 centos6.5.
I hope the function return the return like this
{'www.baidu.com': {'3xx': 0, 'response_time': 0.126, '5xx': 0, '4xx': 1},
'www.google.com': {'3xx': 0, 'response_time': 0, '5xx': 0, '4xx': 0}}
But in fact it is return like that. The send_dict['www.google.com']['response_time'] and send_dict['www.google.com']['response_code'] shouldn't be assigned. But why?
{'www.baidu.com': {'3xx': 0, 'response_time': 0.126, '5xx': 0, '4xx': 1},
'www.google.com': {'3xx': 0, 'response_time': 0.126, '5xx': 0, '4xx': 1}}
The Python code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
sink_dict = {'sink_zabbix_monitor_keys': '3xx,4xx,5xx,response_time',
'sink_zabbix_domain_keys': 'www.baidu.com,www.google.com'}
sub_send_dict = dict.fromkeys(sink_dict['sink_zabbix_monitor_keys'].split(','), 0)
send_dict = dict.fromkeys(sink_dict['sink_zabbix_domain_keys'].split(','), sub_send_dict)
def calculate_item(item):
response_code_dict = dict.fromkeys(sink_dict['sink_zabbix_domain_keys'].split(','), 0)
response_time_dict = dict.fromkeys(sink_dict['sink_zabbix_domain_keys'].split(','), 0)
domain = item['domain']
response_code_dict[domain] = int(item['response_code'])
response_time_dict[domain] = float(item['response_time'])
if domain in send_dict:
print domain
if response_time_dict[domain] > float(send_dict[domain]['response_time']):
send_dict[domain]['response_time'] = response_time_dict[domain]
send_dict[domain][str(response_code_dict[domain])[0] + "xx"] += 1
return send_dict
tmp_item = {'domain': 'www.baidu.com', 'response_time': '0.126', 'response_code': '401'}
tmp_item1 = {'domain': 'www.google.com', 'response_time': '0.126', 'response_code': '401'}
tmp_item2 = {'domain': 'www.baidu.com', 'response_time': '0.166', 'response_code': '401'}
print calculate_item(tmp_item)
Here you go:
send_dict = {k: sub_send_dict.copy() for k in sink_dict['sink_zabbix_domain_keys'].split(',')}
This is called dict comprehension. This works because I'm assigning a shallow copy of the dictionary to the key. dict.fromkeys() will assign the value to every key, all keys will share the same sub_send_dict reference.
From the (linked) python docs:
Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy is sometimes needed so one can change one copy without changing the other.