This project aims to generate simple log files containing current prices on items from your wishlist (and their sum).
This project makes use of the following python3
libs:
urllib
re
json
datetime
threadings
sys
os
bs4
Just follow the steps:
make
./wcalc path/to/file/with/links output/file/directory
./wcalc
- The program itselfpath/to/file/with/links
- A simple text file, containing all the links to be fetch, separated by an newline character (\n
)output/file/directory
- A directory to place the.json
file created after the fetch
Let's say that i have a file on lists/test.txt
with this inside:
https://produto.mercadolivre.com.br/MLB-1146730903-amd-ryzen-2700x-am4-43ghz-octa-core-16theads-rgb-lacrado-_JM
https://produto.mercadolivre.com.br/MLB-1024669523-adaptador-ativo-displayport-p-hdmi-20-4k-60hz-club3d-uhd-_JM
https://produto.mercadolivre.com.br/MLB-960954066-memoria-kingston-hyperx-fury-8gb-2400mhz-ddr4-gamer-cl15-_JM
I could run the program by typing the following commands:
./wcalc lists/test.txt logs
And then, the program will automatically see the domain on the links and select the right API for that site.
At the moment, the API
only extends to the following websites:
mercadolivre
kabum
terabyteshop
(not stable)
I've designed this script to be as modular as you want. So with that in mind, just need some little coding to make this script adapt to your desired website.
You'll need basic knowledge in re
and python3
in order to create your own
API.
With that in mind, follow these steps:
-
Navigate to
src/sites
and create your own website API (ex:google.py
) -
On the source file, follow the guide below:
class Google: def fetch(self, link): # Here you fetch on the link given the information you want # then, after fetched, return a dictionary with the following # keys: # dict['title'] -> product title, need to be a String # dict['price'] -> product price, need to be a Float
-
Then, go to
src/sites/api.py
and include on the header an import to your API, like this:from sites.google import Google # ^your file ^your class
-
And then, add support to your API down there:
# Possible domains and it's correspondent API's domains = { 'kabum.com.br': Kabum, 'terabyteshop.com.br': Terabyte, 'mercadolivre.com.br': ML, 'google.com.br': Google, # ADD THIS LINE }
-
Test your API and feel free to make a Pull Request!
Developed by Felipe Ramos under the MIT License
version 0.2.3