GithubHelp home page GithubHelp logo

216giorgiy / pcpartpicker-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luigi311/pcpartpicker-api

0.0 1.0 0.0 52 KB

An unofficial API to access & scrape data from pcpartpicker.com

Home Page: https://pypi.python.org/pypi/PCPartPicker-API

License: MIT License

Python 94.95% Batchfile 5.05%

pcpartpicker-api's Introduction

PCPartPicker-API

Python3 API for retrieving information from PcPartPicker

What can this API do?

Currently this library contains these features:

  • Select what region you want to use ("uk", "ca", etc.)

  • The productLists class - for interacting with pages that are lists of products, as seen under the "browse by individual parts" tab on the PCPartPicker website (such as products/cpu-cooler). All product lists are supported except the ones under the SOFTWARE catergory, although those may be supported in the future

Installation

pip install PCPartPicker_API

See the PyPi page here

Quickstart

A quick demonstration of what this API can do

# Import pcpartpicker
# Imported here as pcpp to makes lines a little shorter
from PCPartPicker_API import pcpartpicker as pcpp

# Print the total amount of pages for CPUs
print("Total CPU pages:", pcpp.productLists.totalPages("cpu"))

# Pull info from page 1 of CPUs
cpu_info = pcpp.productLists.getProductList("cpu", 1)

# Print the names and prices of all the CPUs on the page
for cpu in cpu_info:
    print(cpu["name"], ":", cpu["price"])

# Change the region to UK (the default is US)
pcpp.setRegion("uk")
print("\nRegion changed to UK")

# Pull info from all CPU pages (this may take a minute)
cpu_info_uk = pcpp.productLists.getProductList("cpu")

# Print the names and prices of all the CPUs on all pages
# The prices will now be in GBP (£) instead of USD ($)
for cpu in cpu_info_uk:
    print(cpu["name"], ":", cpu["price"])

Documentation

To start using the API, import pcpartpicker from PCPartPicker_API

A list of partTypes and their dictionary keys are available in _productsData

pcpartpicker contains these (public) functions:

Function name Paramaters Description
setRegion region The region of PCPartPicker that this API uses. region must be one of: "au", "be", "ca", "de", "es", "fr", "in", "ie", "it", "nz", "uk", "us", case insesetive. The defualt is for this library is "us". As far as I can tell this only changes the currency
productLists.getProductList partType, pageNum=0 This function returns a list of dictionaries. Each partType will have different dictionary keys. To see what keys exist for each partType, you can look them up in _productsData. Every dictionary will always contain the keys name, price, ratings and id (although they may not always have a value). pageNum is set to 0 by default. 0 means it will scrape all pages and gather all the info it can. If you only want to get information from, for example, page 2 of the cpu results, you would set pageNum to 2
productLists.totalPages partType This function simply returns the amount of pages of results there are for a particular partType

ToDo

  • Support the SOFTWARE catergory in pcpartpicker.productLists

pcpartpicker-api's People

Contributors

alexmaday avatar psidex avatar

Watchers

 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.