Giter VIP home page Giter VIP logo

wishlist-scrape's Introduction

Wishlist Scrape

This project aims to generate simple log files containing current prices on items from your wishlist (and their sum).

Dependencies

This project makes use of the following python3 libs:

  • urllib
  • re
  • json
  • datetime
  • threadings
  • sys
  • os
  • bs4

Execution

Just follow the steps:

  1. make
  2. ./wcalc -l path/to/file/with/links -o output/file/directory
usage: wcalc.py [-h] -l list.txt [-o output_file.txt] [-T]

optional arguments:
  -h, --help            show this help message and exit
  -l list.txt           List of products (one link per line)
  -o output_file.json   Output fetched prices
  -T, --no-threading    Disable parallel fetches

Use examples

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.

Supported Websites

At the moment, the API only extends to the following websites:

  • mercadolivre
  • kabum
  • terabyteshop
  • amazon (Outdated)

Creating your custom API

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!

Authorship

Developed by Felipe Ramos under the MIT License

Stats
version     0.2.40

wishlist-scrape's People

Contributors

felipecramos avatar luiz-eduardo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.