-
create accounts.json file at the main directory.
-
add your facebook account's credentials as follows:
"accounts" : [ { "id" : "...", "name" : "...", "email" : "...", "password" : "..." }, ... ]
- Follow The official Instructions by selenium to download a suitable driver for your browser.
- Add the driver to the
drivers
folder. - Make sure to add the driver's filename to the
__init__
function of theLister Class
like the following :self.driver_file = 'chromedriver.exe'
and set the driver's options.
NOTICE : I have set everything for the chrome driver so if you are using chrome browser you will have to just download the driver and add it to the drivers folder,
navigate to the main directory and run pip install -r requirements.txt
on your terminal.
you can check examples.py
file for example usage.
-
title : string | Required | required by facebook. example:
{'title' : 'Cool Product'}
-
price : string | Required | required by facebook. example:
{'price' : '25'}
-
images : list | Required | required by facebook.
- at least one image required.
- images must be placed at the
images
directory. example:{'images' : [ {"file" : "cool_image.png"}, ... ]}
-
location : string | Required | required by facebook.
-
when left empty, default values will be used.
-
you can change default values at the
elements.json
file.example:
{'location' : 'Cairo, Egypt'}
-
-
category : string | Optional | required by facebook.
-
when left empty, default values will be used.
-
you can change default values at the
elements.json
file.example:
{'category' : 'Electronics & computers'}
-
-
condition : string | Optional | required by facebook.
-
when left empty, default values will be used.
-
you can change default values at the
elements.json
file.example:
{'category' : 'New'}
-
-
sku : string | Optional. example:
{'sku' : '564646154'}
-
hide_from_friends : boolean | Optional. set to
True
to hide the listing from your facebook friends. example:{'hide_from_friends' : True}
- create a new instance from
Lister Class
and runlogin
function passing the id of one of the accounts registered ataccounts.json
login
function will returnTrue
on a successful login.- run list function passing a
product
dictionary.
Example :
from Lister import Lister
product = {
'title': '...',
'price': '...',
'images': '[
{'file' : '/image.jpg'},
]',
}
lister = Lister()
my_account_id = 'ma'
if lister.login('ma') :
lister.list(product)
- create a new instance from
Lister Class
and runlogin
function passing the id of one of the accounts registered ataccounts.json
login
function will returnTrue
on a successful login.
Example :
from Lister import Lister
import json
my_json_file = open('products.json', 'r')
products = json.load(my_json_file)['products']
lister = Lister()
my_account_id = 'ma'
if lister.login('ma') :
for product in products :
result = lister.list(product)
if result: print('Success!')