torobot Library
A Python package for interacting with torob.com!
With this library, you can search for products in various cities using different filters.
Set a price range, specify the condition of the product, and more...
You can extract details about registered stores on Torob,
as well as print the vendors’ information (such as contact number, store address, and location).
You can search anonymously, meaning no cookies will be sent from your end to Torob.
Additionally, you have the option to save the above information in any format.
You can store it as an Excel file, an HTML table, or in SQL or JSON format!
Search for goods and stores on torob.com 🍎
pip install torob
Warning
During installation, pandas, bs4 and requests packages are automatically installed, if an error occurs during installation, Install the above packages separately.
import torob
from torob import att
from torob import city
att : To get a series of attributes of the desired product, we import this package .
city : To specify the city, to bring results related to the city ( default = Tehran)
Simple search:
a = torob.Search(‘ps5’)
A little more precise:
a = torob.Search('ps5',range_price=(20000000 , 35000000) , status='new' )
or
a = torob.Search('ps5' , city.MASHHAD , status='stock' ,unknown=True , order='cheap')
goods : The value to search [str]
number : Number of goods received (default 24) [int]
page : search page ( default 0 ) [int]
city : Search city ( default Tehran ) [Select city from ‘city’ module]
in_person : In person (default True ) [bool]
status : Product status (new or stock) ( default None ) [str]
order : Order type (cheap or popular) ( default None ) [str]
range_price : Price range (as a tuple , specifies minimum and maximum price) [tuple]
default = (None , None )
unknown : If it is true, no cookies will be sent by the package to torob.com, so the results will be
different. (default False) [bool]
Number of products found :
print(len(a))
Product category(ies) :
print(a.categorys)
lowest price:
print(a.min_price)
most expensive price:
print(a.max_price)
a.get_images(0)
parameter :
1- index : Product number (0 to len(a) products have been found)
Output :
Returns a list of product image urls
a.get_links()
output:
Returns a list of product addresses
a.get_info(0)
parameter :
1- index : Product number (0 to len(a) products have been found)
2-strip: If set to True, it removes extra spaces
3- out_put_type: Specifies the type of output (list or string) (default str )
4- up_to_page : It repeats this process up to a certain page
Output:
Returns product specifications (as a list or text)
a.get_All(att.NAME_EN ,att.PRICE , only=True ,)
parameter :
1- args : With the help of the imported att class, get the attribute it needs from the
products.
2-only : If it is equal to True, it returns as a list and otherwise it returns as a dictionary.
3-up_to_page : Returns all product details up to the "up_to_page" page
Output:
The dictionary returns the product specifications of this page
a.get_seller(1)
parameter :
1- index : Product number (0 to len(a) products have been found)
2-up_to_page : Returns all product details up to the "up_to_page" page
Output:
It returns the contact number, SMS number, store address and location of the seller
a.get_suggestion()
output :
return list of suggestion
a.get_more_store(0)
parameter :
1- index : Product number (0 to len(a) products have been found)
Output:
It returns the specifications of similar products in other stores.
a.get_similar(0 , short=True)
parameter :
1- index : Product number (0 to len(a) products have been found)
2- short: If it is True; Shows the output more concisely
Output :
Returns a dictionary of similar products (containing the name, price, city and address of
the product photo )
a.save(att.PRICE , att.NAME_FA , formating='excel'
,add_row=True , add_info=True , replaced='ناموجود')
parameters: 1-args: With the help of the imported att class, get the attribute it needs from the products 2-up_to_page : Returns all product details up to the "up_to_page" page 3-formating : Specifies the saved format, it can be equal to the following: A) 'excel' or 'xlsx' or 'xls' or 'e' = To save as Excel
B) 'xml' or 'x' = To save as XML C) 'sql' or 'db' or 's' = To save as SQL D) 'html' or 'h' or 'table' or 'htm' = To save as HTML E) 'str' or 'txt' or 'text' or 'string' = To save as TEXT F) 'hdf5' or 'h5' = To save as HD5 G) 'feather ' or 'pandas' or 'f' = To save as PANDAS format H) 'json' or 'j' = To save as JSON I) 'csv' or 'c' or 'csvx' = To save as CSV 4-replaced : If the product does not have this feature, it replaces this value in the output file (default "-") 5-file_name : Output file name 6-add_info : If it is True, it will add product details to the file with the help of the get_info method (default False) 7- add_row : If it is True, it puts one row (one number) for each product
c = torob.Shop(name='پارس' , count=3)
parameters: 1-name: The name of the desired store 2- count : Number of stores received
print(c.get_information())
print(c.get_count())
print(c.get_address(2))
parameters: 1-index: Which store? store index (from 0 to count-1) can be
print(c.get_score(1))
parameters: 1-index: Which store? store index (from 0 to count-1) can be
print(c.get_license(1))
print(c.get_history(1))